-/* code generator for the Hitachi H8/300 architecture simulator.
- Copyright (C) 1993 Free Software Foundation, Inc.
- Hacked by Steve Chamberlain of Cygnus Support.
+/* Code generator for the Hitachi H8/300 architecture simulator.
-This file is part of BFD, the Binary File Descriptor library.
+ Written by Steve Chamberlain of Cygnus Support.
+ sac@cygnus.com
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This file is part of H8/300 sim
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ Cygnus offers the following for use in the public domain. Cygnus
+ makes no warranty with regard to the software or it's performance
+ and the user accepts the software "AS IS" with all faults.
+
+ CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
+ THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+*/
/* This program reads the H8/300 opcode table and writes out
a large switch statement to understand the opcodes (with ifs if
there is more than one opcode per case) and code to do the stuff */
-#include "bfd.h"
-#include "sysdep.h"
+#include <stdio.h>
#define DEFINE_TABLE
#define INSIM
#include"opcode/h8300.h"
-#define MAXSAME 14
+#define MAXSAME 140
#define PTWO 256
static struct h8_opcode *h8_opcodes_sorted[PTWO][MAXSAME];
{"foo",
"*(blow[b0])",
"*(bhigh[b1])",
- "*(blow[b1])"};
+ "*(blow[b1])",
+ 0, 0,
+ "*(bhigh[pc[1]>>8])"};
/* How to get at a word register from an index in the instruction at
nibble n */
int n1 = 0;
int n2 = 0;
int j;
-
+#if 0
for (j = 0; p->data.nib[j] != E; j++)
{
if ((int) p->data.nib[j] == ABS16ORREL8SRC)
if ((int) p->data.nib[j] == ABS16OR8DST)
p->data.nib[j] = ABS16DST;
}
+#endif
+
if ((int) p->data.nib[0] < 16)
{
n1 = (int) p->data.nib[0];
}
}
-/* either fetch srca&srcb or store dst */
+/* decode the lvalues, creating a pointer in real space to object -
+ remember if the thing has to be swapped out of where it is */
-void
-decode (p, fetch, size)
+
+int swap[2];
+
+lval (p)
struct h8_opcode *p;
- int fetch;
- int size;
{
int i;
- char *ss = size == 8 ? "BYTE" : "WORD";
for (i = 0; p->data.nib[i] != E; i++)
{
- switch (p->data.nib[i])
+ int x = p->data.nib[i];
+ int size;
+ int op;
+ op = (x & DST) ? 1 : 0;
+
+ switch (x & SIZE)
{
- case RS8:
- if (fetch)
- printf ("srca = %s;\n", breg[i]);
+ case L_32:
+ size = 32;
break;
- case RS16 | B30:
- case RS16 | B31:
- case RS16:
- if (fetch)
- printf ("srca = %s;\n", wreg[i]);
+ case L_16:
+ size = 16;
break;
- case RD8:
- if (fetch)
- printf ("srcb = %s;\n", breg[i]);
- else
- printf ("%s = dst;\n", breg[i]);
- break;
- case RD16 | B30:
- case RD16 | B31:
- case RD16:
- if (fetch)
- printf ("srcb = %s;\n", wreg[i]);
- else
- printf ("%s =dst;\n", wreg[i]);
+ case L_8:
+ size = 8;
break;
- case IMM8:
- if (fetch)
- printf ("srca = b1;\n");
- break;
- case RSINC:
- case RSINC | B30:
- case RSINC | B31:
+ default:
+ size = 1234;
+ }
- if (fetch)
- {
- printf ("srca = %s_MEM(%s);\n", ss, wreg[i]);
- printf ("%s+=%d;\n", wreg[i], size / 8);
- }
- break;
- case RSIND:
- case RSIND | B30:
- case RSIND | B31:
- if (fetch)
- {
- printf ("lval = %s;\n", wreg[i]);
- printf ("srca = %s_MEM(lval);\n", ss);
- }
- break;
+ if (x & REG)
+ {
+ printf ("ir%d = GET_LVAL_%d_REG(%d);\n", op, size, i);
+ }
+ else if (x & IMM)
+ {
+ printf ("/* Imm has no lvalue */\n");
+ }
- case RDIND:
- case RDIND | B30:
- case RDIND | B31:
- if (fetch)
- {
- printf ("lval = %s;\n", wreg[i]);
- printf ("srcb = %s_MEM(lval);\n", ss);
- }
- else
- {
- printf ("SET_%s_MEM(lval,dst);\n", ss);
- }
- break;
+ }
- case MEMIND:
- if (fetch)
- {
- printf ("lval = pc[1];\n");
- }
- break;
- case RDDEC:
- case RDDEC | B30:
- case RDDEC | B31:
- if (!fetch)
- {
- printf ("%s -=%d;\n", wreg[i], size / 8);
- printf ("SET_%s_MEM(%s, dst);\n", ss, wreg[i]);
- }
- break;
- case IMM3:
- case IMM3 | B31:
- case IMM3 | B30:
- if (fetch)
- printf ("srca = %s;\n", imm3[i]);
- break;
- case IMM16:
- if (fetch)
- printf ("srca =( pc[1]);\n");
- break;
- case ABS8SRC:
- if (fetch)
- {
- printf ("lval = (0xff00) + b1;\n");
- printf ("srca = BYTE_MEM(lval);\n");
- }
+}
- break;
- case ABS8DST:
- if (fetch)
- {
- printf ("lval = (0xff00) + b1;\n");
- printf ("srcb = BYTE_MEM(lval);\n");
- }
- else
- {
- printf ("SET_BYTE_MEM(lval,dst);\n");
- }
- break;
- case KBIT:
- if (fetch)
- printf ("srca = ((b1&0x80)?2:1);\n");
- break;
- case ABS16ORREL8SRC:
- case ABS16SRC:
- if (fetch)
- {
- printf ("lval = pc[1];\n");
- printf ("srca = %s_MEM(lval);\n", size == 8 ? "BYTE" : "WORD");
- }
- break;
- case DISPREG | B30:
- case DISPREG | B31:
- case DISPREG:
- printf ("rn = %s & 0x7;\n", nibs[i]);
- break;
- case DISPSRC:
- if (fetch)
- {
- printf ("lval = 0xffff&(pc[1] +reg[rn]);\n");
- printf ("srca = %s_MEM(lval);\n", size == 8 ? "BYTE" : "WORD");
- }
- break;
- case DISPDST:
- if (fetch)
- {
- printf ("lval = 0xffff&(pc[1] +reg[rn]);\n");
- printf ("srcb = %s_MEM(lval);\n", size == 8 ? "BYTE" : "WORD");
- }
- else
- {
- printf ("SET_%s_MEM(lval,dst);\n", ss);
- }
- break;
- case ABS16DST:
- if (fetch)
- {
- printf ("lval = (pc[1]);\n");
- printf ("srcb = %s_MEM(lval);\n", ss);
- }
- else
- {
- printf ("SET_%s_MEM(lval,dst);\n", ss);
- }
- break;
- case IGNORE:
- break;
- case DISP8:
- printf (" /* DISP8 handled in opcode */\n");
- break;
- default:
- if (p->data.nib[i] > HexF)
- {
- printf ("saved_state.exception = SIGILL;\n");
- }
- }
+void
+decode (p, fetch, size)
+ struct h8_opcode *p;
+ int fetch;
+ int size;
+{
+ if (fetch)
+ {
+ lval (p);
}
+
}
+
+
static void
esleep ()
{
}
-table [] =
+table[] =
{
{
nx, 1, "bld", bit, "dst = srcb; c = (srcb>>srca)&1;", 8
printf ("case 0x%03x:\n", i);
}
- /* Dont need any if's this is the only one */
+ /* Don't need any if's this is the only one */
edo (*p);
}
else