Back to index

cell-binutils  2.17cvs20070401
z8kgen.c
Go to the documentation of this file.
00001 /* Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
00002 
00003    This file is part of GNU Binutils.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
00018    USA.  */
00019 
00020 /* This program generates z8k-opc.h.  Compile with -fwritable-strings.  */
00021 
00022 #include <stdio.h>
00023 #include "sysdep.h"
00024 #include "libiberty.h"
00025 
00026 #define BYTE_INFO_LEN 10
00027 
00028 struct op
00029 {
00030   char *flags;
00031   int cycles;
00032   char type;
00033   char *bits;
00034   char *name;
00035   char *flavor;
00036 };
00037 
00038 #define iswhite(x) ((x) == ' ' || (x) == '\t')
00039 static struct op opt[] =
00040 {
00041   {"------", 2,  8, "0011 0110 0000 0000", "bpt", 0},   /* Breakpoint used by the simulator.  */
00042   {"------", 10, 8, "0000 1111 0000 1100", "brk", 0},   /* Breakpoint used by real hardware.
00043                                                            (ext0f #0x0c).  */
00044 
00045   {"------", 10, 8, "0000 1110 imm8", "ext0e imm8", 0},
00046   {"------", 10, 8, "0000 1111 imm8", "ext0f imm8", 0},
00047   {"------", 10, 8, "1000 1110 imm8", "ext8e imm8", 0},
00048   {"------", 10, 8, "1000 1111 imm8", "ext8f imm8", 0},
00049 
00050   {"------", 10, 8, "0011 0110 imm8", "rsvd36", 0},
00051   {"------", 10, 8, "0011 1000 imm8", "rsvd38", 0},
00052   {"------", 10, 8, "0111 1000 imm8", "rsvd78", 0},
00053   {"------", 10, 8, "0111 1110 imm8", "rsvd7e", 0},
00054 
00055   {"------", 10, 8, "1001 1101 imm8", "rsvd9d", 0},
00056   {"------", 10, 8, "1001 1111 imm8", "rsvd9f", 0},
00057 
00058   {"------", 10, 8, "1011 1001 imm8", "rsvdb9", 0},
00059   {"------", 10, 8, "1011 1111 imm8", "rsvdbf", 0},
00060 
00061   {"---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 1000", "ldd @rd,@rs,rr", 0},
00062   {"---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 0000", "lddr @rd,@rs,rr", 0},
00063   {"---V--", 11, 8, "1011 1010 ssN0 1001 0000 rrrr ddN0 0000", "lddrb @rd,@rs,rr", 0},
00064   {"---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 0000", "ldir @rd,@rs,rr", 0},
00065   {"CZSV--", 11, 16, "1011 1011 ssN0 0000 0000 rrrr dddd cccc", "cpi rd,@rs,rr,cc", 0},
00066   {"CZSV--", 11, 16, "1011 1011 ssN0 0100 0000 rrrr dddd cccc", "cpir rd,@rs,rr,cc", 0},
00067   {"CZSV--", 11, 16, "1011 1011 ssN0 1100 0000 rrrr dddd cccc", "cpdr rd,@rs,rr,cc", 0},
00068   {"---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 1000", "ldi @rd,@rs,rr", 0},
00069   {"CZSV--", 11, 16, "1011 1011 ssN0 1000 0000 rrrr dddd cccc", "cpd rd,@rs,rr,cc", 0},
00070   {"---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 0000", "ldirb @rd,@rs,rr", 0},
00071   {"---V--", 11, 8, "1011 1010 ssN0 1001 0000 rrrr ddN0 1000", "lddb @rd,@rs,rr", 0},
00072   {"---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 1000", "ldib @rd,@rs,rr", 0},
00073   {"CZSV--", 11, 8, "1011 1010 ssN0 1000 0000 rrrr dddd cccc", "cpdb rbd,@rs,rr,cc", 0},
00074   {"CZSV--", 11, 8, "1011 1010 ssN0 1100 0000 rrrr dddd cccc", "cpdrb rbd,@rs,rr,cc", 0},
00075   {"CZSV--", 11, 8, "1011 1010 ssN0 0000 0000 rrrr dddd cccc", "cpib rbd,@rs,rr,cc", 0},
00076   {"CZSV--", 11, 8, "1011 1010 ssN0 0100 0000 rrrr dddd cccc", "cpirb rbd,@rs,rr,cc", 0},
00077   {"CZSV--", 11, 16, "1011 1011 ssN0 1010 0000 rrrr ddN0 cccc", "cpsd @rd,@rs,rr,cc", 0},
00078   {"CZSV--", 11, 8, "1011 1010 ssN0 1010 0000 rrrr ddN0 cccc", "cpsdb @rd,@rs,rr,cc", 0},
00079   {"CZSV--", 11, 16, "1011 1011 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdr @rd,@rs,rr,cc", 0},
00080   {"CZSV--", 11, 8, "1011 1010 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdrb @rd,@rs,rr,cc", 0},
00081   {"CZSV--", 11, 16, "1011 1011 ssN0 0010 0000 rrrr ddN0 cccc", "cpsi @rd,@rs,rr,cc", 0},
00082   {"CZSV--", 11, 8, "1011 1010 ssN0 0010 0000 rrrr ddN0 cccc", "cpsib @rd,@rs,rr,cc", 0},
00083   {"CZSV--", 11, 16, "1011 1011 ssN0 0110 0000 rrrr ddN0 cccc", "cpsir @rd,@rs,rr,cc", 0},
00084   {"CZSV--", 11, 8, "1011 1010 ssN0 0110 0000 rrrr ddN0 cccc", "cpsirb @rd,@rs,rr,cc", 0},
00085 
00086   {"CZSV--", 5, 16, "1011 0101 ssss dddd", "adc rd,rs", 0},
00087   {"CZSVDH", 5, 8, "1011 0100 ssss dddd", "adcb rbd,rbs", 0},
00088   {"CZSV--", 7, 16, "0000 0001 ssN0 dddd", "add rd,@rs", 0},
00089   {"CZSV--", 9, 16, "0100 0001 0000 dddd address_src", "add rd,address_src", 0},
00090   {"CZSV--", 10, 16, "0100 0001 ssN0 dddd address_src", "add rd,address_src(rs)", 0},
00091   {"CZSV--", 7, 16, "0000 0001 0000 dddd imm16", "add rd,imm16", 0},
00092   {"CZSV--", 4, 16, "1000 0001 ssss dddd", "add rd,rs", 0},
00093   {"CZSVDH", 7, 8, "0000 0000 ssN0 dddd", "addb rbd,@rs", 0},
00094   {"CZSVDH", 9, 8, "0100 0000 0000 dddd address_src", "addb rbd,address_src", 0},
00095   {"CZSVDH", 10, 8, "0100 0000 ssN0 dddd address_src", "addb rbd,address_src(rs)", 0},
00096   {"CZSVDH", 7, 8, "0000 0000 0000 dddd imm8 imm8", "addb rbd,imm8", 0},
00097   {"CZSVDH", 4, 8, "1000 0000 ssss dddd", "addb rbd,rbs", 0},
00098   {"CZSV--", 14, 32, "0001 0110 ssN0 dddd", "addl rrd,@rs", 0},
00099   {"CZSV--", 15, 32, "0101 0110 0000 dddd address_src", "addl rrd,address_src", 0},
00100   {"CZSV--", 16, 32, "0101 0110 ssN0 dddd address_src", "addl rrd,address_src(rs)", 0},
00101   {"CZSV--", 14, 32, "0001 0110 0000 dddd imm32", "addl rrd,imm32", 0},
00102   {"CZSV--", 8, 32, "1001 0110 ssss dddd", "addl rrd,rrs", 0},
00103 
00104   {"-ZS---", 7, 16, "0000 0111 ssN0 dddd", "and rd,@rs", 0},
00105   {"-ZS---", 9, 16, "0100 0111 0000 dddd address_src", "and rd,address_src", 0},
00106   {"-ZS---", 10, 16, "0100 0111 ssN0 dddd address_src", "and rd,address_src(rs)", 0},
00107   {"-ZS---", 7, 16, "0000 0111 0000 dddd imm16", "and rd,imm16", 0},
00108   {"-ZS---", 4, 16, "1000 0111 ssss dddd", "and rd,rs", 0},
00109   {"-ZSP--", 7, 8, "0000 0110 ssN0 dddd", "andb rbd,@rs", 0},
00110   {"-ZSP--", 9, 8, "0100 0110 0000 dddd address_src", "andb rbd,address_src", 0},
00111   {"-ZSP--", 10, 8, "0100 0110 ssN0 dddd address_src", "andb rbd,address_src(rs)", 0},
00112   {"-ZSP--", 7, 8, "0000 0110 0000 dddd imm8 imm8", "andb rbd,imm8", 0},
00113   {"-ZSP--", 4, 8, "1000 0110 ssss dddd", "andb rbd,rbs", 0},
00114 
00115   {"-Z----", 8, 16, "0010 0111 ddN0 imm4", "bit @rd,imm4", 0},
00116   {"-Z----", 11, 16, "0110 0111 ddN0 imm4 address_dst", "bit address_dst(rd),imm4", 0},
00117   {"-Z----", 10, 16, "0110 0111 0000 imm4 address_dst", "bit address_dst,imm4", 0},
00118   {"-Z----", 4, 16, "1010 0111 dddd imm4", "bit rd,imm4", 0},
00119   {"-Z----", 10, 16, "0010 0111 0000 ssss 0000 dddd 0000 0000", "bit rd,rs", 0},
00120 
00121   {"-Z----", 8, 8, "0010 0110 ddN0 imm4", "bitb @rd,imm4", 0},
00122   {"-Z----", 11, 8, "0110 0110 ddN0 imm4 address_dst", "bitb address_dst(rd),imm4", 0},
00123   {"-Z----", 10, 8, "0110 0110 0000 imm4 address_dst", "bitb address_dst,imm4", 0},
00124   {"-Z----", 4, 8, "1010 0110 dddd imm4", "bitb rbd,imm4", 0},
00125   {"-Z----", 10, 8, "0010 0110 0000 ssss 0000 dddd 0000 0000", "bitb rbd,rs", 0},
00126 
00127   {"------", 10, 32, "0001 1111 ddN0 0000", "call @rd", 0},
00128   {"------", 12, 32, "0101 1111 0000 0000 address_dst", "call address_dst", 0},
00129   {"------", 13, 32, "0101 1111 ddN0 0000 address_dst", "call address_dst(rd)", 0},
00130   {"------", 10, 16, "1101 disp12", "calr disp12", 0},
00131 
00132   {"------", 8, 16, "0000 1101 ddN0 1000", "clr @rd", 0},
00133   {"------", 11, 16, "0100 1101 0000 1000 address_dst", "clr address_dst", 0},
00134   {"------", 12, 16, "0100 1101 ddN0 1000 address_dst", "clr address_dst(rd)", 0},
00135   {"------", 7, 16, "1000 1101 dddd 1000", "clr rd", 0},
00136   {"------", 8, 8, "0000 1100 ddN0 1000", "clrb @rd", 0},
00137   {"------", 11, 8, "0100 1100 0000 1000 address_dst", "clrb address_dst", 0},
00138   {"------", 12, 8, "0100 1100 ddN0 1000 address_dst", "clrb address_dst(rd)", 0},
00139   {"------", 7, 8, "1000 1100 dddd 1000", "clrb rbd", 0},
00140   {"-ZS---", 12, 16, "0000 1101 ddN0 0000", "com @rd", 0},
00141   {"-ZS---", 15, 16, "0100 1101 0000 0000 address_dst", "com address_dst", 0},
00142   {"-ZS---", 16, 16, "0100 1101 ddN0 0000 address_dst", "com address_dst(rd)", 0},
00143   {"-ZS---", 7, 16, "1000 1101 dddd 0000", "com rd", 0},
00144   {"-ZSP--", 12, 8, "0000 1100 ddN0 0000", "comb @rd", 0},
00145   {"-ZSP--", 15, 8, "0100 1100 0000 0000 address_dst", "comb address_dst", 0},
00146   {"-ZSP--", 16, 8, "0100 1100 ddN0 0000 address_dst", "comb address_dst(rd)", 0},
00147   {"-ZSP--", 7, 8, "1000 1100 dddd 0000", "comb rbd", 0},
00148   {"CZSP--", 7, 16, "1000 1101 flags 0101", "comflg flags", 0},
00149 
00150   {"CZSV--", 11, 16, "0000 1101 ddN0 0001 imm16", "cp @rd,imm16", 0},
00151   {"CZSV--", 15, 16, "0100 1101 ddN0 0001 address_dst imm16", "cp address_dst(rd),imm16", 0},
00152   {"CZSV--", 14, 16, "0100 1101 0000 0001 address_dst imm16", "cp address_dst,imm16", 0},
00153 
00154   {"CZSV--", 7, 16, "0000 1011 ssN0 dddd", "cp rd,@rs", 0},
00155   {"CZSV--", 9, 16, "0100 1011 0000 dddd address_src", "cp rd,address_src", 0},
00156   {"CZSV--", 10, 16, "0100 1011 ssN0 dddd address_src", "cp rd,address_src(rs)", 0},
00157   {"CZSV--", 7, 16, "0000 1011 0000 dddd imm16", "cp rd,imm16", 0},
00158   {"CZSV--", 4, 16, "1000 1011 ssss dddd", "cp rd,rs", 0},
00159 
00160   {"CZSV--", 11, 8, "0000 1100 ddN0 0001 imm8 imm8", "cpb @rd,imm8", 0},
00161   {"CZSV--", 15, 8, "0100 1100 ddN0 0001 address_dst imm8 imm8", "cpb address_dst(rd),imm8", 0},
00162   {"CZSV--", 14, 8, "0100 1100 0000 0001 address_dst imm8 imm8", "cpb address_dst,imm8", 0},
00163   {"CZSV--", 7, 8, "0000 1010 ssN0 dddd", "cpb rbd,@rs", 0},
00164   {"CZSV--", 9, 8, "0100 1010 0000 dddd address_src", "cpb rbd,address_src", 0},
00165   {"CZSV--", 10, 8, "0100 1010 ssN0 dddd address_src", "cpb rbd,address_src(rs)", 0},
00166   {"CZSV--", 7, 8, "0000 1010 0000 dddd imm8 imm8", "cpb rbd,imm8", 0},
00167   {"CZSV--", 4, 8, "1000 1010 ssss dddd", "cpb rbd,rbs", 0},
00168 
00169   {"CZSV--", 14, 32, "0001 0000 ssN0 dddd", "cpl rrd,@rs", 0},
00170   {"CZSV--", 15, 32, "0101 0000 0000 dddd address_src", "cpl rrd,address_src", 0},
00171   {"CZSV--", 16, 32, "0101 0000 ssN0 dddd address_src", "cpl rrd,address_src(rs)", 0},
00172   {"CZSV--", 14, 32, "0001 0000 0000 dddd imm32", "cpl rrd,imm32", 0},
00173   {"CZSV--", 8, 32, "1001 0000 ssss dddd", "cpl rrd,rrs", 0},
00174 
00175   {"CZS---", 5, 8, "1011 0000 dddd 0000", "dab rbd", 0},
00176   {"------", 11, 16, "1111 dddd 0disp7", "dbjnz rbd,disp7", 0},
00177   {"-ZSV--", 11, 16, "0010 1011 ddN0 imm4m1", "dec @rd,imm4m1", 0},
00178   {"-ZSV--", 14, 16, "0110 1011 ddN0 imm4m1 address_dst", "dec address_dst(rd),imm4m1", 0},
00179   {"-ZSV--", 13, 16, "0110 1011 0000 imm4m1 address_dst", "dec address_dst,imm4m1", 0},
00180   {"-ZSV--", 4, 16, "1010 1011 dddd imm4m1", "dec rd,imm4m1", 0},
00181   {"-ZSV--", 11, 8, "0010 1010 ddN0 imm4m1", "decb @rd,imm4m1", 0},
00182   {"-ZSV--", 14, 8, "0110 1010 ddN0 imm4m1 address_dst", "decb address_dst(rd),imm4m1", 0},
00183   {"-ZSV--", 13, 8, "0110 1010 0000 imm4m1 address_dst", "decb address_dst,imm4m1", 0},
00184   {"-ZSV--", 4, 8, "1010 1010 dddd imm4m1", "decb rbd,imm4m1", 0},
00185 
00186   {"------", 7, 16, "0111 1100 0000 00ii", "di i2", 0},
00187   {"CZSV--", 107, 16, "0001 1011 ssN0 dddd", "div rrd,@rs", 0},
00188   {"CZSV--", 107, 16, "0101 1011 0000 dddd address_src", "div rrd,address_src", 0},
00189   {"CZSV--", 107, 16, "0101 1011 ssN0 dddd address_src", "div rrd,address_src(rs)", 0},
00190   {"CZSV--", 107, 16, "0001 1011 0000 dddd imm16", "div rrd,imm16", 0},
00191   {"CZSV--", 107, 16, "1001 1011 ssss dddd", "div rrd,rs", 0},
00192   {"CZSV--", 744, 32, "0001 1010 ssN0 dddd", "divl rqd,@rs", 0},
00193   {"CZSV--", 745, 32, "0101 1010 0000 dddd address_src", "divl rqd,address_src", 0},
00194   {"CZSV--", 746, 32, "0101 1010 ssN0 dddd address_src", "divl rqd,address_src(rs)", 0},
00195   {"CZSV--", 744, 32, "0001 1010 0000 dddd imm32", "divl rqd,imm32", 0},
00196   {"CZSV--", 744, 32, "1001 1010 ssss dddd", "divl rqd,rrs", 0},
00197 
00198   {"------", 11, 16, "1111 dddd 1disp7", "djnz rd,disp7", 0},
00199   {"------", 7, 16, "0111 1100 0000 01ii", "ei i2", 0},
00200   {"------", 6, 16, "1010 1101 ssss dddd", "ex rd,rs", 0},
00201   {"------", 12, 16, "0010 1101 ssN0 dddd", "ex rd,@rs", 0},
00202   {"------", 15, 16, "0110 1101 0000 dddd address_src", "ex rd,address_src", 0},
00203   {"------", 16, 16, "0110 1101 ssN0 dddd address_src", "ex rd,address_src(rs)", 0},
00204 
00205   {"------", 12, 8, "0010 1100 ssN0 dddd", "exb rbd,@rs", 0},
00206   {"------", 15, 8, "0110 1100 0000 dddd address_src", "exb rbd,address_src", 0},
00207   {"------", 16, 8, "0110 1100 ssN0 dddd address_src", "exb rbd,address_src(rs)", 0},
00208   {"------", 6, 8, "1010 1100 ssss dddd", "exb rbd,rbs", 0},
00209 
00210   {"------", 11, 16, "1011 0001 dddd 1010", "exts rrd", 0},
00211   {"------", 11, 8, "1011 0001 dddd 0000", "extsb rd", 0},
00212   {"------", 11, 32, "1011 0001 dddd 0111", "extsl rqd", 0},
00213 
00214   {"------", 8, 16, "0111 1010 0000 0000", "halt", 0},
00215   {"------", 10, 16, "0011 1101 ssss dddd", "in rd,@ri", 0},
00216   {"------", 12, 8, "0011 1100 ssss dddd", "inb rbd,@ri", 0},
00217   {"------", 12, 16, "0011 1011 dddd 0100 imm16", "in rd,imm16", 0},
00218   {"------", 10, 8, "0011 1010 dddd 0100 imm16", "inb rbd,imm16", 0},
00219   {"-ZSV--", 11, 16, "0010 1001 ddN0 imm4m1", "inc @rd,imm4m1", 0},
00220   {"-ZSV--", 14, 16, "0110 1001 ddN0 imm4m1 address_dst", "inc address_dst(rd),imm4m1", 0},
00221   {"-ZSV--", 13, 16, "0110 1001 0000 imm4m1 address_dst", "inc address_dst,imm4m1", 0},
00222   {"-ZSV--", 4, 16, "1010 1001 dddd imm4m1", "inc rd,imm4m1", 0},
00223   {"-ZSV--", 11, 8, "0010 1000 ddN0 imm4m1", "incb @rd,imm4m1", 0},
00224   {"-ZSV--", 14, 8, "0110 1000 ddN0 imm4m1 address_dst", "incb address_dst(rd),imm4m1", 0},
00225   {"-ZSV--", 13, 8, "0110 1000 0000 imm4m1 address_dst", "incb address_dst,imm4m1", 0},
00226   {"-ZSV--", 4, 8, "1010 1000 dddd imm4m1", "incb rbd,imm4m1", 0},
00227   {"---V--", 21, 16, "0011 1011 ssss 1000 0000 aaaa ddN0 1000", "ind @rd,@ri,ra", 0},
00228   {"---V--", 21, 8, "0011 1010 ssss 1000 0000 aaaa ddN0 1000", "indb @rd,@ri,ra", 0},
00229   {"---V--", 11, 16, "0011 1011 ssss 1000 0000 aaaa ddN0 0000", "indr @rd,@ri,ra", 0},
00230   {"---V--", 11, 8, "0011 1010 ssss 1000 0000 aaaa ddN0 0000", "indrb @rd,@ri,ra", 0},
00231   {"---V--", 21, 16, "0011 1011 ssss 0000 0000 aaaa ddN0 1000", "ini @rd,@ri,ra", 0},
00232   {"---V--", 21, 8, "0011 1010 ssss 0000 0000 aaaa ddN0 1000", "inib @rd,@ri,ra", 0},
00233   {"---V--", 11, 16, "0011 1011 ssss 0000 0000 aaaa ddN0 0000", "inir @rd,@ri,ra", 0},
00234   {"---V--", 11, 8, "0011 1010 ssss 0000 0000 aaaa ddN0 0000", "inirb @rd,@ri,ra", 0},
00235   {"CZSVDH", 13, 16, "0111 1011 0000 0000", "iret", 0},
00236   {"------", 10, 16, "0001 1110 ddN0 cccc", "jp cc,@rd", 0},
00237   {"------", 7, 16, "0101 1110 0000 cccc address_dst", "jp cc,address_dst", 0},
00238   {"------", 8, 16, "0101 1110 ddN0 cccc address_dst", "jp cc,address_dst(rd)", 0},
00239   {"------", 6, 16, "1110 cccc disp8", "jr cc,disp8", 0},
00240 
00241   {"------", 7, 16, "0000 1101 ddN0 0101 imm16", "ld @rd,imm16", 0},
00242   {"------", 8, 16, "0010 1111 ddN0 ssss", "ld @rd,rs", 0},
00243   {"------", 15, 16, "0100 1101 ddN0 0101 address_dst imm16", "ld address_dst(rd),imm16", 0},
00244   {"------", 12, 16, "0110 1111 ddN0 ssss address_dst", "ld address_dst(rd),rs", 0},
00245   {"------", 14, 16, "0100 1101 0000 0101 address_dst imm16", "ld address_dst,imm16", 0},
00246   {"------", 11, 16, "0110 1111 0000 ssss address_dst", "ld address_dst,rs", 0},
00247   {"------", 14, 16, "0011 0011 ddN0 ssss imm16", "ld rd(imm16),rs", 0},
00248   {"------", 14, 16, "0111 0011 ddN0 ssss 0000 xxxx 0000 0000", "ld rd(rx),rs", 0},
00249   {"------", 7, 16, "0010 0001 ssN0 dddd", "ld rd,@rs", 0},
00250   {"------", 9, 16, "0110 0001 0000 dddd address_src", "ld rd,address_src", 0},
00251   {"------", 10, 16, "0110 0001 ssN0 dddd address_src", "ld rd,address_src(rs)", 0},
00252   {"------", 7, 16, "0010 0001 0000 dddd imm16", "ld rd,imm16", 0},
00253   {"------", 3, 16, "1010 0001 ssss dddd", "ld rd,rs", 0},
00254   {"------", 14, 16, "0011 0001 ssN0 dddd imm16", "ld rd,rs(imm16)", 0},
00255   {"------", 14, 16, "0111 0001 ssN0 dddd 0000 xxxx 0000 0000", "ld rd,rs(rx)", 0},
00256 
00257   {"------", 7, 8, "0000 1100 ddN0 0101 imm8 imm8", "ldb @rd,imm8", 0},
00258   {"------", 8, 8, "0010 1110 ddN0 ssss", "ldb @rd,rbs", 0},
00259   {"------", 15, 8, "0100 1100 ddN0 0101 address_dst imm8 imm8", "ldb address_dst(rd),imm8", 0},
00260   {"------", 12, 8, "0110 1110 ddN0 ssss address_dst", "ldb address_dst(rd),rbs", 0},
00261   {"------", 14, 8, "0100 1100 0000 0101 address_dst imm8 imm8", "ldb address_dst,imm8", 0},
00262   {"------", 11, 8, "0110 1110 0000 ssss address_dst", "ldb address_dst,rbs", 0},
00263   {"------", 14, 8, "0011 0010 ddN0 ssss imm16", "ldb rd(imm16),rbs", 0},
00264   {"------", 14, 8, "0111 0010 ddN0 ssss 0000 xxxx 0000 0000", "ldb rd(rx),rbs", 0},
00265   {"------", 7, 8, "0010 0000 ssN0 dddd", "ldb rbd,@rs", 0},
00266   {"------", 9, 8, "0110 0000 0000 dddd address_src", "ldb rbd,address_src", 0},
00267   {"------", 10, 8, "0110 0000 ssN0 dddd address_src", "ldb rbd,address_src(rs)", 0},
00268   {"------", 5, 8, "1100 dddd imm8", "ldb rbd,imm8", 0},
00269   {"------", 7, 8, "0010 0000 0000 dddd imm8 imm8", "ldb rbd,imm8", 0},
00270   {"------", 3, 8, "1010 0000 ssss dddd", "ldb rbd,rbs", 0},
00271   {"------", 14, 8, "0011 0000 ssN0 dddd imm16", "ldb rbd,rs(imm16)", 0},
00272   {"------", 14, 8, "0111 0000 ssN0 dddd 0000 xxxx 0000 0000", "ldb rbd,rs(rx)", 0},
00273 
00274   {"------", 11, 32, "0001 1101 ddN0 ssss", "ldl @rd,rrs", 0},
00275   {"------", 14, 32, "0101 1101 ddN0 ssss address_dst", "ldl address_dst(rd),rrs", 0},
00276   {"------", 15, 32, "0101 1101 0000 ssss address_dst", "ldl address_dst,rrs", 0},
00277   {"------", 17, 32, "0011 0111 ddN0 ssss imm16", "ldl rd(imm16),rrs", 0},
00278   {"------", 17, 32, "0111 0111 ddN0 ssss 0000 xxxx 0000 0000", "ldl rd(rx),rrs", 0},
00279   {"------", 11, 32, "0001 0100 ssN0 dddd", "ldl rrd,@rs", 0},
00280   {"------", 12, 32, "0101 0100 0000 dddd address_src", "ldl rrd,address_src", 0},
00281   {"------", 13, 32, "0101 0100 ssN0 dddd address_src", "ldl rrd,address_src(rs)", 0},
00282   {"------", 11, 32, "0001 0100 0000 dddd imm32", "ldl rrd,imm32", 0},
00283   {"------", 5, 32, "1001 0100 ssss dddd", "ldl rrd,rrs", 0},
00284   {"------", 17, 32, "0011 0101 ssN0 dddd imm16", "ldl rrd,rs(imm16)", 0},
00285   {"------", 17, 32, "0111 0101 ssN0 dddd 0000 xxxx 0000 0000", "ldl rrd,rs(rx)", 0},
00286 
00287   {"------", 12, 16, "0111 0110 0000 dddd address_src", "lda prd,address_src", 0},
00288   {"------", 13, 16, "0111 0110 ssN0 dddd address_src", "lda prd,address_src(rs)", 0},
00289   {"------", 15, 16, "0011 0100 ssN0 dddd imm16", "lda prd,rs(imm16)", 0},
00290   {"------", 15, 16, "0111 0100 ssN0 dddd 0000 xxxx 0000 0000", "lda prd,rs(rx)", 0},
00291   {"------", 15, 16, "0011 0100 0000 dddd disp16", "ldar prd,disp16", 0},
00292   {"------", 7, 32, "0111 1101 ssss 1ccc", "ldctl ctrl,rs", 0},
00293   {"------", 7, 32, "0111 1101 dddd 0ccc", "ldctl rd,ctrl", 0},
00294 
00295   {"------", 5, 16, "1011 1101 dddd imm4", "ldk rd,imm4", 0},
00296 
00297   {"------", 11, 16, "0001 1100 ddN0 1001 0000 ssss 0000 imm4m1", "ldm @rd,rs,n", 0},
00298   {"------", 15, 16, "0101 1100 ddN0 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst(rd),rs,n", 0},
00299   {"------", 14, 16, "0101 1100 0000 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst,rs,n", 0},
00300   {"------", 11, 16, "0001 1100 ssN0 0001 0000 dddd 0000 imm4m1", "ldm rd,@rs,n", 0},
00301   {"------", 15, 16, "0101 1100 ssN0 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src(rs),n", 0},
00302   {"------", 14, 16, "0101 1100 0000 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src,n", 0},
00303 
00304   {"CZSVDH", 12, 16, "0011 1001 ssN0 0000", "ldps @rs", 0},
00305   {"CZSVDH", 16, 16, "0111 1001 0000 0000 address_src", "ldps address_src", 0},
00306   {"CZSVDH", 17, 16, "0111 1001 ssN0 0000 address_src", "ldps address_src(rs)", 0},
00307 
00308   {"------", 14, 16, "0011 0011 0000 ssss disp16", "ldr disp16,rs", 0},
00309   {"------", 14, 16, "0011 0001 0000 dddd disp16", "ldr rd,disp16", 0},
00310   {"------", 14, 8, "0011 0010 0000 ssss disp16", "ldrb disp16,rbs", 0},
00311   {"------", 14, 8, "0011 0000 0000 dddd disp16", "ldrb rbd,disp16", 0},
00312   {"------", 17, 32, "0011 0111 0000 ssss disp16", "ldrl disp16,rrs", 0},
00313   {"------", 17, 32, "0011 0101 0000 dddd disp16", "ldrl rrd,disp16", 0},
00314 
00315   {"CZS---", 7, 16, "0111 1011 0000 1010", "mbit", 0},
00316   {"-ZS---", 12, 16, "0111 1011 dddd 1101", "mreq rd", 0},
00317   {"------", 5, 16, "0111 1011 0000 1001", "mres", 0},
00318   {"------", 5, 16, "0111 1011 0000 1000", "mset", 0},
00319 
00320   {"CZSV--", 70, 16, "0001 1001 ssN0 dddd", "mult rrd,@rs", 0},
00321   {"CZSV--", 70, 16, "0101 1001 0000 dddd address_src", "mult rrd,address_src", 0},
00322   {"CZSV--", 70, 16, "0101 1001 ssN0 dddd address_src", "mult rrd,address_src(rs)", 0},
00323   {"CZSV--", 70, 16, "0001 1001 0000 dddd imm16", "mult rrd,imm16", 0},
00324   {"CZSV--", 70, 16, "1001 1001 ssss dddd", "mult rrd,rs", 0},
00325   {"CZSV--", 282, 32, "0001 1000 ssN0 dddd", "multl rqd,@rs", 0},
00326   {"CZSV--", 282, 32, "0101 1000 0000 dddd address_src", "multl rqd,address_src", 0},
00327   {"CZSV--", 282, 32, "0101 1000 ssN0 dddd address_src", "multl rqd,address_src(rs)", 0},
00328   {"CZSV--", 282, 32, "0001 1000 0000 dddd imm32", "multl rqd,imm32", 0},
00329   {"CZSV--", 282, 32, "1001 1000 ssss dddd", "multl rqd,rrs", 0},
00330   {"CZSV--", 12, 16, "0000 1101 ddN0 0010", "neg @rd", 0},
00331   {"CZSV--", 15, 16, "0100 1101 0000 0010 address_dst", "neg address_dst", 0},
00332   {"CZSV--", 16, 16, "0100 1101 ddN0 0010 address_dst", "neg address_dst(rd)", 0},
00333   {"CZSV--", 7, 16, "1000 1101 dddd 0010", "neg rd", 0},
00334   {"CZSV--", 12, 8, "0000 1100 ddN0 0010", "negb @rd", 0},
00335   {"CZSV--", 15, 8, "0100 1100 0000 0010 address_dst", "negb address_dst", 0},
00336   {"CZSV--", 16, 8, "0100 1100 ddN0 0010 address_dst", "negb address_dst(rd)", 0},
00337   {"CZSV--", 7, 8, "1000 1100 dddd 0010", "negb rbd", 0},
00338 
00339   {"------", 7, 16, "1000 1101 0000 0111", "nop", 0},
00340 
00341   {"CZS---", 7, 16, "0000 0101 ssN0 dddd", "or rd,@rs", 0},
00342   {"CZS---", 9, 16, "0100 0101 0000 dddd address_src", "or rd,address_src", 0},
00343   {"CZS---", 10, 16, "0100 0101 ssN0 dddd address_src", "or rd,address_src(rs)", 0},
00344   {"CZS---", 7, 16, "0000 0101 0000 dddd imm16", "or rd,imm16", 0},
00345   {"CZS---", 4, 16, "1000 0101 ssss dddd", "or rd,rs", 0},
00346 
00347   {"CZSP--", 7, 8, "0000 0100 ssN0 dddd", "orb rbd,@rs", 0},
00348   {"CZSP--", 9, 8, "0100 0100 0000 dddd address_src", "orb rbd,address_src", 0},
00349   {"CZSP--", 10, 8, "0100 0100 ssN0 dddd address_src", "orb rbd,address_src(rs)", 0},
00350   {"CZSP--", 7, 8, "0000 0100 0000 dddd imm8 imm8", "orb rbd,imm8", 0},
00351   {"CZSP--", 4, 8, "1000 0100 ssss dddd", "orb rbd,rbs", 0},
00352 
00353   {"------", 10, 16, "0011 1111 dddd ssss", "out @ro,rs", 0},
00354   {"------", 12, 16, "0011 1011 ssss 0110 imm16", "out imm16,rs", 0},
00355   {"------", 10, 8, "0011 1110 dddd ssss", "outb @ro,rbs", 0},
00356   {"------", 12, 8, "0011 1010 ssss 0110 imm16", "outb imm16,rbs", 0},
00357   {"---V--", 21, 16, "0011 1011 ssN0 1010 0000 aaaa dddd 1000", "outd @ro,@rs,ra", 0},
00358   {"---V--", 21, 8, "0011 1010 ssN0 1010 0000 aaaa dddd 1000", "outdb @ro,@rs,ra", 0},
00359   {"---V--", 11, 16, "0011 1011 ssN0 1010 0000 aaaa dddd 0000", "otdr @ro,@rs,ra", 0},
00360   {"---V--", 11, 8, "0011 1010 ssN0 1010 0000 aaaa dddd 0000", "otdrb @ro,@rs,ra", 0},
00361   {"---V--", 21, 16, "0011 1011 ssN0 0010 0000 aaaa dddd 1000", "outi @ro,@rs,ra", 0},
00362   {"---V--", 21, 8, "0011 1010 ssN0 0010 0000 aaaa dddd 1000", "outib @ro,@rs,ra", 0},
00363   {"---V--", 11, 16, "0011 1011 ssN0 0010 0000 aaaa dddd 0000", "otir @ro,@rs,ra", 0},
00364   {"---V--", 11, 8, "0011 1010 ssN0 0010 0000 aaaa dddd 0000", "otirb @ro,@rs,ra", 0},
00365 
00366   {"------", 12, 16, "0001 0111 ssN0 ddN0", "pop @rd,@rs", 0},
00367   {"------", 16, 16, "0101 0111 ssN0 ddN0 address_dst", "pop address_dst(rd),@rs", 0},
00368   {"------", 16, 16, "0101 0111 ssN0 0000 address_dst", "pop address_dst,@rs", 0},
00369   {"------", 8, 16, "1001 0111 ssN0 dddd", "pop rd,@rs", 0},
00370 
00371   {"------", 19, 32, "0001 0101 ssN0 ddN0", "popl @rd,@rs", 0},
00372   {"------", 23, 32, "0101 0101 ssN0 ddN0 address_dst", "popl address_dst(rd),@rs", 0},
00373   {"------", 23, 32, "0101 0101 ssN0 0000 address_dst", "popl address_dst,@rs", 0},
00374   {"------", 12, 32, "1001 0101 ssN0 dddd", "popl rrd,@rs", 0},
00375 
00376   {"------", 13, 16, "0001 0011 ddN0 ssN0", "push @rd,@rs", 0},
00377   {"------", 14, 16, "0101 0011 ddN0 0000 address_src", "push @rd,address_src", 0},
00378   {"------", 14, 16, "0101 0011 ddN0 ssN0 address_src", "push @rd,address_src(rs)", 0},
00379   {"------", 12, 16, "0000 1101 ddN0 1001 imm16", "push @rd,imm16", 0},
00380   {"------", 9, 16, "1001 0011 ddN0 ssss", "push @rd,rs", 0},
00381 
00382   {"------", 20, 32, "0001 0001 ddN0 ssN0", "pushl @rd,@rs", 0},
00383   {"------", 21, 32, "0101 0001 ddN0 ssN0 address_src", "pushl @rd,address_src(rs)", 0},
00384   {"------", 21, 32, "0101 0001 ddN0 0000 address_src", "pushl @rd,address_src", 0},
00385   {"------", 12, 32, "1001 0001 ddN0 ssss", "pushl @rd,rrs", 0},
00386 
00387   {"------", 11, 16, "0010 0011 ddN0 imm4", "res @rd,imm4", 0},
00388   {"------", 14, 16, "0110 0011 ddN0 imm4 address_dst", "res address_dst(rd),imm4", 0},
00389   {"------", 13, 16, "0110 0011 0000 imm4 address_dst", "res address_dst,imm4", 0},
00390   {"------", 4, 16, "1010 0011 dddd imm4", "res rd,imm4", 0},
00391   {"------", 10, 16, "0010 0011 0000 ssss 0000 dddd 0000 0000", "res rd,rs", 0},
00392 
00393   {"------", 11, 8, "0010 0010 ddN0 imm4", "resb @rd,imm4", 0},
00394   {"------", 14, 8, "0110 0010 ddN0 imm4 address_dst", "resb address_dst(rd),imm4", 0},
00395   {"------", 13, 8, "0110 0010 0000 imm4 address_dst", "resb address_dst,imm4", 0},
00396   {"------", 4, 8, "1010 0010 dddd imm4", "resb rbd,imm4", 0},
00397   {"------", 10, 8, "0010 0010 0000 ssss 0000 dddd 0000 0000", "resb rbd,rs", 0},
00398 
00399   {"CZSV--", 7, 16, "1000 1101 flags 0011", "resflg flags", 0},
00400   {"------", 10, 16, "1001 1110 0000 cccc", "ret cc", 0},
00401 
00402   {"CZSV--", 6, 16, "1011 0011 dddd 00I0", "rl rd,imm1or2", 0},
00403   {"CZSV--", 6, 8, "1011 0010 dddd 00I0", "rlb rbd,imm1or2", 0},
00404   {"CZSV--", 6, 16, "1011 0011 dddd 10I0", "rlc rd,imm1or2", 0},
00405 
00406   {"-Z----", 9, 8, "1011 0010 dddd 10I0", "rlcb rbd,imm1or2", 0},
00407   {"-Z----", 9, 8, "1011 1110 aaaa bbbb", "rldb rbb,rba", 0},
00408 
00409   {"CZSV--", 6, 16, "1011 0011 dddd 01I0", "rr rd,imm1or2", 0},
00410   {"CZSV--", 6, 8, "1011 0010 dddd 01I0", "rrb rbd,imm1or2", 0},
00411   {"CZSV--", 6, 16, "1011 0011 dddd 11I0", "rrc rd,imm1or2", 0},
00412 
00413   {"-Z----", 9, 8, "1011 0010 dddd 11I0", "rrcb rbd,imm1or2", 0},
00414   {"-Z----", 9, 8, "1011 1100 aaaa bbbb", "rrdb rbb,rba", 0},
00415   {"CZSV--", 5, 16, "1011 0111 ssss dddd", "sbc rd,rs", 0},
00416   {"CZSVDH", 5, 8, "1011 0110 ssss dddd", "sbcb rbd,rbs", 0},
00417 
00418   {"CZSVDH", 33, 8, "0111 1111 imm8", "sc imm8", 0},
00419 
00420   {"CZSV--", 15, 16, "1011 0011 dddd 1011 0000 ssss 0000 0000", "sda rd,rs", 0},
00421   {"CZSV--", 15, 8, "1011 0010 dddd 1011 0000 ssss 0000 0000", "sdab rbd,rs", 0},
00422   {"CZSV--", 15, 32, "1011 0011 dddd 1111 0000 ssss 0000 0000", "sdal rrd,rs", 0},
00423 
00424   {"CZS---", 15, 16, "1011 0011 dddd 0011 0000 ssss 0000 0000", "sdl rd,rs", 0},
00425   {"CZS---", 15, 8, "1011 0010 dddd 0011 0000 ssss 0000 0000", "sdlb rbd,rs", 0},
00426   {"CZS---", 15, 32, "1011 0011 dddd 0111 0000 ssss 0000 0000", "sdll rrd,rs", 0},
00427 
00428   {"------", 11, 16, "0010 0101 ddN0 imm4", "set @rd,imm4", 0},
00429   {"------", 14, 16, "0110 0101 ddN0 imm4 address_dst", "set address_dst(rd),imm4", 0},
00430   {"------", 13, 16, "0110 0101 0000 imm4 address_dst", "set address_dst,imm4", 0},
00431   {"------", 4, 16, "1010 0101 dddd imm4", "set rd,imm4", 0},
00432   {"------", 10, 16, "0010 0101 0000 ssss 0000 dddd 0000 0000", "set rd,rs", 0},
00433   {"------", 11, 8, "0010 0100 ddN0 imm4", "setb @rd,imm4", 0},
00434   {"------", 14, 8, "0110 0100 ddN0 imm4 address_dst", "setb address_dst(rd),imm4", 0},
00435   {"------", 13, 8, "0110 0100 0000 imm4 address_dst", "setb address_dst,imm4", 0},
00436   {"------", 4, 8, "1010 0100 dddd imm4", "setb rbd,imm4", 0},
00437   {"------", 10, 8, "0010 0100 0000 ssss 0000 dddd 0000 0000", "setb rbd,rs", 0},
00438 
00439   {"CZSV--", 7, 16, "1000 1101 flags 0001", "setflg flags", 0},
00440 
00441   {"------", 12, 16, "0011 1011 dddd 0101 imm16", "sin rd,imm16", 0},
00442   {"------", 10, 8, "0011 1010 dddd 0101 imm16", "sinb rbd,imm16", 0},
00443   {"---V--", 21, 16, "0011 1011 ssss 1001 0000 aaaa ddN0 1000", "sind @rd,@ri,ra", 0},
00444   {"---V--", 21, 8, "0011 1010 ssss 1001 0000 aaaa ddN0 1000", "sindb @rd,@ri,ra", 0},
00445   {"---V--", 11, 16, "0011 1011 ssss 1001 0000 aaaa ddN0 0000", "sindr @rd,@ri,ra", 0},
00446   {"---V--", 11, 8, "0011 1010 ssss 1001 0000 aaaa ddN0 0000", "sindrb @rd,@ri,ra", 0},
00447   {"---V--", 21, 16, "0011 1011 ssss 0001 0000 aaaa ddN0 1000", "sini @rd,@ri,ra", 0},
00448   {"---V--", 21, 8, "0011 1010 ssss 0001 0000 aaaa ddN0 1000", "sinib @rd,@ri,ra", 0},
00449   {"---V--", 11, 16, "0011 1011 ssss 0001 0000 aaaa ddN0 0000", "sinir @rd,@ri,ra", 0},
00450   {"---V--", 11, 8, "0011 1010 ssss 0001 0000 aaaa ddN0 0000", "sinirb @rd,@ri,ra", 0},
00451 
00452   {"CZSV--", 13, 16, "1011 0011 dddd 1001 0000 0000 imm8", "sla rd,imm8", 0},
00453   {"CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 0000 imm4", "slab rbd,imm4", 0},
00454   {"CZSV--", 13, 32, "1011 0011 dddd 1101 0000 0000 imm8", "slal rrd,imm8", 0},
00455 
00456   {"CZS---", 13, 16, "1011 0011 dddd 0001 0000 0000 imm8", "sll rd,imm8", 0},
00457   {"CZS---", 13, 8, "1011 0010 dddd 0001 iiii iiii 0000 imm4", "sllb rbd,imm4", 0},
00458   {"CZS---", 13, 32, "1011 0011 dddd 0101 0000 0000 imm8", "slll rrd,imm8", 0},
00459 
00460   {"------", 12, 16, "0011 1011 ssss 0110 imm16", "sout imm16,rs", 0},
00461   {"------", 12, 8, "0011 1010 ssss 0110 imm16", "soutb imm16,rbs", 0},
00462   {"---V--", 21, 16, "0011 1011 ssN0 1011 0000 aaaa dddd 1000", "soutd @ro,@rs,ra", 0},
00463   {"---V--", 21, 8, "0011 1010 ssN0 1011 0000 aaaa dddd 1000", "soutdb @ro,@rs,ra", 0},
00464   {"---V--", 11, 16, "0011 1011 ssN0 1011 0000 aaaa dddd 0000", "sotdr @ro,@rs,ra", 0},
00465   {"---V--", 11, 8, "0011 1010 ssN0 1011 0000 aaaa dddd 0000", "sotdrb @ro,@rs,ra", 0},
00466   {"---V--", 21, 16, "0011 1011 ssN0 0011 0000 aaaa dddd 1000", "souti @ro,@rs,ra", 0},
00467   {"---V--", 21, 8, "0011 1010 ssN0 0011 0000 aaaa dddd 1000", "soutib @ro,@rs,ra", 0},
00468   {"---V--", 11, 16, "0011 1011 ssN0 0011 0000 aaaa dddd 0000", "sotir @ro,@rs,ra", 0},
00469   {"---V--", 11, 8, "0011 1010 ssN0 0011 0000 aaaa dddd 0000", "sotirb @ro,@rs,ra", 0},
00470 
00471   {"CZSV--", 13, 16, "1011 0011 dddd 1001 1111 1111 nim8", "sra rd,imm8", 0},
00472   {"CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 1111 nim4", "srab rbd,imm4", 0},
00473   {"CZSV--", 13, 32, "1011 0011 dddd 1101 1111 1111 nim8", "sral rrd,imm8", 0},
00474 
00475   {"CZSV--", 13, 16, "1011 0011 dddd 0001 1111 1111 nim8", "srl rd,imm8", 0},
00476   {"CZSV--", 13, 8, "1011 0010 dddd 0001 iiii iiii 1111 nim4", "srlb rbd,imm4", 0},
00477   {"CZSV--", 13, 32, "1011 0011 dddd 0101 1111 1111 nim8", "srll rrd,imm8", 0},
00478 
00479   {"CZSV--", 7, 16, "0000 0011 ssN0 dddd", "sub rd,@rs", 0},
00480   {"CZSV--", 9, 16, "0100 0011 0000 dddd address_src", "sub rd,address_src", 0},
00481   {"CZSV--", 10, 16, "0100 0011 ssN0 dddd address_src", "sub rd,address_src(rs)", 0},
00482   {"CZSV--", 7, 16, "0000 0011 0000 dddd imm16", "sub rd,imm16", 0},
00483   {"CZSV--", 4, 16, "1000 0011 ssss dddd", "sub rd,rs", 0},
00484 
00485   {"CZSVDH", 7, 8, "0000 0010 ssN0 dddd", "subb rbd,@rs", 0},
00486   {"CZSVDH", 9, 8, "0100 0010 0000 dddd address_src", "subb rbd,address_src", 0},
00487   {"CZSVDH", 10, 8, "0100 0010 ssN0 dddd address_src", "subb rbd,address_src(rs)", 0},
00488   {"CZSVDH", 7, 8, "0000 0010 0000 dddd imm8 imm8", "subb rbd,imm8", 0},
00489   {"CZSVDH", 4, 8, "1000 0010 ssss dddd", "subb rbd,rbs", 0},
00490 
00491   {"CZSV--", 14, 32, "0001 0010 ssN0 dddd", "subl rrd,@rs", 0},
00492   {"CZSV--", 15, 32, "0101 0010 0000 dddd address_src", "subl rrd,address_src", 0},
00493   {"CZSV--", 16, 32, "0101 0010 ssN0 dddd address_src", "subl rrd,address_src(rs)", 0},
00494   {"CZSV--", 14, 32, "0001 0010 0000 dddd imm32", "subl rrd,imm32", 0},
00495   {"CZSV--", 8, 32, "1001 0010 ssss dddd", "subl rrd,rrs", 0},
00496 
00497   {"------", 5, 16, "1010 1111 dddd cccc", "tcc cc,rd", 0},
00498   {"------", 5, 8, "1010 1110 dddd cccc", "tccb cc,rbd", 0},
00499 
00500   {"-ZS---", 8, 16, "0000 1101 ddN0 0100", "test @rd", 0},
00501   {"------", 11, 16, "0100 1101 0000 0100 address_dst", "test address_dst", 0},
00502   {"------", 12, 16, "0100 1101 ddN0 0100 address_dst", "test address_dst(rd)", 0},
00503   {"------", 7, 16, "1000 1101 dddd 0100", "test rd", 0},
00504 
00505   {"-ZSP--", 8, 8, "0000 1100 ddN0 0100", "testb @rd", 0},
00506   {"-ZSP--", 11, 8, "0100 1100 0000 0100 address_dst", "testb address_dst", 0},
00507   {"-ZSP--", 12, 8, "0100 1100 ddN0 0100 address_dst", "testb address_dst(rd)", 0},
00508   {"-ZSP--", 7, 8, "1000 1100 dddd 0100", "testb rbd", 0},
00509 
00510   {"-ZS---", 13, 32, "0001 1100 ddN0 1000", "testl @rd", 0},
00511   {"-ZS---", 16, 32, "0101 1100 0000 1000 address_dst", "testl address_dst", 0},
00512   {"-ZS---", 17, 32, "0101 1100 ddN0 1000 address_dst", "testl address_dst(rd)", 0},
00513   {"-ZS---", 13, 32, "1001 1100 dddd 1000", "testl rrd", 0},
00514 
00515   {"-ZSV--", 25, 8, "1011 1000 ddN0 1000 0000 aaaa ssN0 0000", "trdb @rd,@rs,rba", 0},
00516   {"-ZSV--", 25, 8, "1011 1000 ddN0 1100 0000 aaaa ssN0 0000", "trdrb @rd,@rs,rba", 0},
00517   {"-ZSV--", 25, 8, "1011 1000 ddN0 0000 0000 rrrr ssN0 0000", "trib @rd,@rs,rbr", 0},
00518   {"-ZSV--", 25, 8, "1011 1000 ddN0 0100 0000 rrrr ssN0 0000", "trirb @rd,@rs,rbr", 0},
00519   {"-ZSV--", 25, 8, "1011 1000 aaN0 1010 0000 rrrr bbN0 0000", "trtdb @ra,@rb,rbr", 0},
00520   {"-ZSV--", 25, 8, "1011 1000 aaN0 1110 0000 rrrr bbN0 1110", "trtdrb @ra,@rb,rbr", 0},
00521   {"-ZSV--", 25, 8, "1011 1000 aaN0 0010 0000 rrrr bbN0 0000", "trtib @ra,@rb,rbr", 0},
00522   {"-ZSV--", 25, 8, "1011 1000 aaN0 0110 0000 rrrr bbN0 1110", "trtirb @ra,@rb,rbr", 0},
00523   {"-ZSV--", 25, 8, "1011 1000 aaN0 1010 0000 rrrr bbN0 0000", "trtrb @ra,@rb,rbr", 0},
00524 
00525   {"--S---", 11, 16, "0000 1101 ddN0 0110", "tset @rd", 0},
00526   {"--S---", 14, 16, "0100 1101 0000 0110 address_dst", "tset address_dst", 0},
00527   {"--S---", 15, 16, "0100 1101 ddN0 0110 address_dst", "tset address_dst(rd)", 0},
00528   {"--S---", 7, 16, "1000 1101 dddd 0110", "tset rd", 0},
00529 
00530   {"--S---", 11, 8, "0000 1100 ddN0 0110", "tsetb @rd", 0},
00531   {"--S---", 14, 8, "0100 1100 0000 0110 address_dst", "tsetb address_dst", 0},
00532   {"--S---", 15, 8, "0100 1100 ddN0 0110 address_dst", "tsetb address_dst(rd)", 0},
00533   {"--S---", 7, 8, "1000 1100 dddd 0110", "tsetb rbd", 0},
00534 
00535   {"-ZS---", 7, 16, "0000 1001 ssN0 dddd", "xor rd,@rs", 0},
00536   {"-ZS---", 9, 16, "0100 1001 0000 dddd address_src", "xor rd,address_src", 0},
00537   {"-ZS---", 10, 16, "0100 1001 ssN0 dddd address_src", "xor rd,address_src(rs)", 0},
00538   {"-ZS---", 7, 16, "0000 1001 0000 dddd imm16", "xor rd,imm16", 0},
00539   {"-ZS---", 4, 16, "1000 1001 ssss dddd", "xor rd,rs", 0},
00540 
00541   {"-ZSP--", 7, 8, "0000 1000 ssN0 dddd", "xorb rbd,@rs", 0},
00542   {"-ZSP--", 9, 8, "0100 1000 0000 dddd address_src", "xorb rbd,address_src", 0},
00543   {"-ZSP--", 10, 8, "0100 1000 ssN0 dddd address_src", "xorb rbd,address_src(rs)", 0},
00544   {"-ZSP--", 7, 8, "0000 1000 0000 dddd imm8 imm8", "xorb rbd,imm8", 0},
00545   {"-ZSP--", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
00546 
00547   {"------", 7, 32, "1000 1100 dddd 0001", "ldctlb rbd,ctrl", 0},
00548   {"CZSVDH", 7, 32, "1000 1100 ssss 1001", "ldctlb ctrl,rbs", 0},
00549 
00550   {"*", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
00551   {"*", 0, 0, 0, 0, 0}
00552 };
00553 
00554 static int
00555 count (void)
00556 {
00557   struct op *p = opt;
00558   int r = 0;
00559 
00560   while (p->name)
00561     {
00562       r++;
00563       p++;
00564     }
00565   return r;
00566 
00567 }
00568 
00569 static int
00570 func (struct op *a, struct op *b)
00571 {
00572   return strcmp ((a)->name, (b)->name);
00573 }
00574 
00575 
00576 /* opcode
00577 
00578  literal  0000 nnnn insert nnn into stream
00579  operand  0001 nnnn  insert operand reg nnn into stream
00580 */
00581 
00582 struct tok_struct
00583 {
00584   char *match;
00585   char *token;
00586   int length;
00587 };
00588 
00589 static struct tok_struct args[] =
00590 {
00591   {"address_src(rs)", "CLASS_X+(ARG_RS)",},
00592   {"address_dst(rd)", "CLASS_X+(ARG_RD)",},
00593 
00594   {"rs(imm16)", "CLASS_BA+(ARG_RS)",},
00595   {"rd(imm16)", "CLASS_BA+(ARG_RD)",},
00596   {"prd",       "CLASS_PR+(ARG_RD)",},
00597   {"address_src", "CLASS_DA+(ARG_SRC)",},
00598   {"address_dst", "CLASS_DA+(ARG_DST)",},
00599   {"rd(rx)", "CLASS_BX+(ARG_RD)",},
00600   {"rs(rx)", "CLASS_BX+(ARG_RS)",},
00601 
00602   {"disp16", "CLASS_DISP",},
00603   {"disp12", "CLASS_DISP",},
00604   {"disp7", "CLASS_DISP",},
00605   {"disp8", "CLASS_DISP",},
00606   {"flags", "CLASS_FLAGS",},
00607 
00608   {"imm16", "CLASS_IMM+(ARG_IMM16)",},
00609   {"imm1or2", "CLASS_IMM+(ARG_IMM1OR2)",},
00610   {"imm32", "CLASS_IMM+(ARG_IMM32)",},
00611   {"imm4m1", "CLASS_IMM +(ARG_IMM4M1)",},
00612   {"imm4", "CLASS_IMM +(ARG_IMM4)",},
00613   {"n", "CLASS_IMM + (ARG_IMM4M1)",},
00614   {"ctrl", "CLASS_CTRL",},
00615   {"rba", "CLASS_REG_BYTE+(ARG_RA)",},
00616   {"rbb", "CLASS_REG_BYTE+(ARG_RB)",},
00617   {"rbd", "CLASS_REG_BYTE+(ARG_RD)",},
00618   {"rbs", "CLASS_REG_BYTE+(ARG_RS)",},
00619   {"rbr", "CLASS_REG_BYTE+(ARG_RR)",},
00620 
00621   {"rrd", "CLASS_REG_LONG+(ARG_RD)",},
00622   {"rrs", "CLASS_REG_LONG+(ARG_RS)",},
00623 
00624   {"rqd", "CLASS_REG_QUAD+(ARG_RD)",},
00625 
00626   {"rd", "CLASS_REG_WORD+(ARG_RD)",},
00627   {"rs", "CLASS_REG_WORD+(ARG_RS)",},
00628 
00629   {"@rd", "CLASS_IR+(ARG_RD)",},
00630   {"@ra", "CLASS_IR+(ARG_RA)",},
00631   {"@rb", "CLASS_IR+(ARG_RB)",},
00632   {"@rs", "CLASS_IR+(ARG_RS)",},
00633   {"@ri", "CLASS_IRO+(ARG_RS)",},
00634   {"@ro", "CLASS_IRO+(ARG_RD)",},
00635 
00636   {"imm8", "CLASS_IMM+(ARG_IMM8)",},
00637   {"i2", "CLASS_IMM+(ARG_IMM2)",},
00638   {"cc", "CLASS_CC",},
00639 
00640   {"rr", "CLASS_REG_WORD+(ARG_RR)",},
00641   {"ra", "CLASS_REG_WORD+(ARG_RA)",},
00642   {"rs", "CLASS_REG_WORD+(ARG_RS)",},
00643 
00644   {"1", "CLASS_IMM+(ARG_IMM_1)",},
00645   {"2", "CLASS_IMM+(ARG_IMM_2)",},
00646 
00647   {0, 0}
00648 };
00649 
00650 static struct tok_struct toks[] =
00651 {
00652   {"0000", "CLASS_BIT+0", 1},
00653   {"0001", "CLASS_BIT+1", 1},
00654   {"0010", "CLASS_BIT+2", 1},
00655   {"0011", "CLASS_BIT+3", 1},
00656   {"0100", "CLASS_BIT+4", 1},
00657   {"0101", "CLASS_BIT+5", 1},
00658   {"0110", "CLASS_BIT+6", 1},
00659   {"0111", "CLASS_BIT+7", 1},
00660   {"1000", "CLASS_BIT+8", 1},
00661   {"1001", "CLASS_BIT+9", 1},
00662   {"1010", "CLASS_BIT+0xa", 1},
00663   {"1011", "CLASS_BIT+0xb", 1},
00664   {"1100", "CLASS_BIT+0xc", 1},
00665   {"1101", "CLASS_BIT+0xd", 1},
00666   {"1110", "CLASS_BIT+0xe", 1},
00667   {"1111", "CLASS_BIT+0xf", 1},
00668 
00669   {"00I0", "CLASS_BIT_1OR2+0", 1},
00670   {"00I0", "CLASS_BIT_1OR2+1", 1},
00671   {"00I0", "CLASS_BIT_1OR2+2", 1},
00672   {"00I0", "CLASS_BIT_1OR2+3", 1},
00673   {"01I0", "CLASS_BIT_1OR2+4", 1},
00674   {"01I0", "CLASS_BIT_1OR2+5", 1},
00675   {"01I0", "CLASS_BIT_1OR2+6", 1},
00676   {"01I0", "CLASS_BIT_1OR2+7", 1},
00677   {"10I0", "CLASS_BIT_1OR2+8", 1},
00678   {"10I0", "CLASS_BIT_1OR2+9", 1},
00679   {"10I0", "CLASS_BIT_1OR2+0xa", 1},
00680   {"10I0", "CLASS_BIT_1OR2+0xb", 1},
00681   {"11I0", "CLASS_BIT_1OR2+0xc", 1},
00682   {"11I0", "CLASS_BIT_1OR2+0xd", 1},
00683   {"11I0", "CLASS_BIT_1OR2+0xe", 1},
00684   {"11I0", "CLASS_BIT_1OR2+0xf", 1},
00685 
00686   {"ssss", "CLASS_REG+(ARG_RS)", 1},
00687   {"dddd", "CLASS_REG+(ARG_RD)", 1},
00688   {"aaaa", "CLASS_REG+(ARG_RA)", 1},
00689   {"bbbb", "CLASS_REG+(ARG_RB)", 1},
00690   {"rrrr", "CLASS_REG+(ARG_RR)", 1},
00691 
00692   {"ssN0", "CLASS_REGN0+(ARG_RS)", 1},
00693   {"ddN0", "CLASS_REGN0+(ARG_RD)", 1},
00694   {"aaN0", "CLASS_REGN0+(ARG_RA)", 1},
00695   {"bbN0", "CLASS_REGN0+(ARG_RB)", 1},
00696   {"rrN0", "CLASS_REGN0+(ARG_RR)", 1},
00697 
00698   {"cccc", "CLASS_CC", 1},
00699   {"nnnn", "CLASS_IMM+(ARG_IMMN)", 1},
00700   {"xxxx", "CLASS_REG+(ARG_RX)", 1},
00701   {"xxN0", "CLASS_REGN0+(ARG_RX)", 1},
00702   {"nminus1", "CLASS_IMM+(ARG_IMMNMINUS1)", 1},
00703 
00704   {"disp16", "CLASS_DISP+(ARG_DISP16)", 4},
00705   {"disp12", "CLASS_DISP+(ARG_DISP12)", 3},
00706   {"flags", "CLASS_FLAGS", 1},
00707   {"address_dst", "CLASS_ADDRESS+(ARG_DST)", 4},
00708   {"address_src", "CLASS_ADDRESS+(ARG_SRC)", 4},
00709   {"imm4m1", "CLASS_IMM+(ARG_IMM4M1)", 1},
00710   {"imm4", "CLASS_IMM+(ARG_IMM4)", 1},
00711 
00712   {"imm8", "CLASS_IMM+(ARG_IMM8)", 2},
00713   {"imm16", "CLASS_IMM+(ARG_IMM16)", 4},
00714   {"imm32", "CLASS_IMM+(ARG_IMM32)", 8},
00715   {"nim4", "CLASS_IMM+(ARG_NIM4)", 2},
00716   {"nim8", "CLASS_IMM+(ARG_NIM8)", 2},
00717   {"0ccc", "CLASS_0CCC", 1},
00718   {"1ccc", "CLASS_1CCC", 1},
00719   {"disp8", "CLASS_DISP8", 2},
00720   {"0disp7", "CLASS_0DISP7", 2},
00721   {"1disp7", "CLASS_1DISP7", 2},
00722   {"01ii", "CLASS_01II", 1},
00723   {"00ii", "CLASS_00II", 1},
00724 
00725   {"iiii", "CLASS_IGNORE", 1},
00726   {0, 0}
00727 };
00728 
00729 static char *
00730 translate (struct tok_struct *table, char *x, int *length)
00731 {
00732 
00733   int found;
00734 
00735   found = 0;
00736   while (table->match)
00737     {
00738       int l = strlen (table->match);
00739 
00740       if (strncmp (table->match, x, l) == 0)
00741        {
00742          /* Got a hit */
00743          printf ("%s", table->token);
00744          *length += table->length;
00745          return x + l;
00746        }
00747 
00748       table++;
00749     }
00750   fprintf (stderr, "Can't find %s\n", x);
00751   printf ("**** Can't find %s\n", x);
00752   while (*x)
00753     x++;
00754   return x;
00755 }
00756 
00757 static void
00758 chewbits (char *bits, int *length)
00759 {
00760   int n = 0;
00761 
00762   *length = 0;
00763   printf ("{");
00764   while (*bits)
00765     {
00766       while (*bits == ' ')
00767        {
00768          bits++;
00769        }
00770       bits = translate (toks, bits, length);
00771       n++;
00772       printf (",");
00773 
00774     }
00775   while (n < BYTE_INFO_LEN - 1)
00776     {
00777       printf ("0,");
00778       n++;
00779     }
00780   printf ("}");
00781 }
00782 
00783 static int
00784 chewname (char **name)
00785 {
00786   char *n;
00787   int nargs = 0;
00788 
00789   n = *name;
00790   while (*n && !iswhite (*n))
00791     n++;
00792 
00793   if (*n)
00794     {
00795       size_t len = n - *name;
00796       char *newname = xmalloc (len + 1);
00797       memcpy (newname, *name, len);
00798       newname[len] = 0;
00799       *name = newname;
00800     }
00801 
00802   printf ("\"%s\",OPC_%s,0,{", *name, *name);
00803 
00804   /* Scan the operands and make entries for them.
00805      Remember indirect things.  */
00806   while (*n)
00807     {
00808       int d;
00809 
00810       while (*n == ',' || iswhite (*n))
00811        n++;
00812       nargs++;
00813       n = translate (args, n, &d);
00814       printf (",");
00815     }
00816   if (nargs == 0)
00817     {
00818       printf ("0");
00819     }
00820   printf ("},");
00821   return nargs;
00822 }
00823 
00824 static void
00825 sub (char *x, char c)
00826 {
00827   while (*x)
00828     {
00829       if (x[0] == c && x[1] == c &&
00830          x[2] == c && x[3] == c)
00831        {
00832          x[2] = 'N';
00833          x[3] = '0';
00834        }
00835       x++;
00836     }
00837 }
00838 
00839 
00840 #if 0
00841 #define D(x) ((x) == '1' || (x) =='0')
00842 #define M(y) (strncmp(y,x,4)==0)
00843 static void
00844 printmangled (char *x)
00845 {
00846   return;
00847   while (*x)
00848     {
00849       if (D (x[0]) && D (x[1]) && D (x[2]) && D (x[3]))
00850        {
00851          printf ("XXXX");
00852        }
00853       else if (M ("ssss"))
00854        {
00855          printf ("ssss");
00856        }
00857       else if (M ("dddd"))
00858        {
00859          printf ("dddd");
00860        }
00861       else
00862        printf ("____");
00863 
00864       x += 4;
00865 
00866       if (x[0] == ' ')
00867        {
00868          printf ("_");
00869          x++;
00870        }
00871     }
00872 
00873 }
00874 #endif
00875 
00876 /*#define WORK_TYPE*/
00877 static void
00878 print_type (struct op *n)
00879 {
00880 #ifdef WORK_TYPE
00881   while (*s && !iswhite (*s))
00882     {
00883       l = *s;
00884       s++;
00885     }
00886   switch (l)
00887     {
00888     case 'l':
00889       printf ("32,");
00890       break;
00891     case 'b':
00892       printf ("8,");
00893       break;
00894     default:
00895       printf ("16,");
00896       break;
00897     }
00898 #else
00899   printf ("%2d,", n->type);
00900 #endif
00901 }
00902 
00903 static void
00904 internal (void)
00905 {
00906   int c = count ();
00907   struct op *new = xmalloc (sizeof (struct op) * c);
00908   struct op *p = opt;
00909   memcpy (new, p, c * sizeof (struct op));
00910 
00911   /* Sort all names in table alphabetically.  */
00912   qsort (new, c, sizeof (struct op), (int (*)(const void *, const void *))func);
00913 
00914   p = new;
00915   while (p->flags && p->flags[0] != '*')
00916   {
00917     /* If there are any @rs, sub the ssss into a ssn0, (rs), (ssn0).  */
00918     int loop = 1;
00919 
00920     printf ("\"%s\",%2d, ", p->flags, p->cycles);
00921     while (loop)
00922     {
00923       char *s = p->name;
00924 
00925       loop = 0;
00926       while (*s)
00927       {
00928        if (s[0] == '@')
00929        {
00930          char c;
00931 
00932          /* Skip the r and sub the string.  */
00933          s++;
00934          c = s[1];
00935          sub (p->bits, c);
00936        }
00937        if (s[0] == '(' && s[3] == ')')
00938        {
00939          sub (p->bits, s[2]);
00940        }
00941        if (s[0] == '(')
00942        {
00943          sub (p->bits, s[-1]);
00944        }
00945 
00946        s++;
00947       }
00948 
00949     }
00950     print_type (p);
00951     printf ("\"%s\",\"%s\",0,\n", p->bits, p->name);
00952     p++;
00953   }
00954 }
00955 
00956 static void
00957 gas (void)
00958 {
00959   int c = count ();
00960   struct op *p = opt;
00961   int idx = -1;
00962   char *oldname = "";
00963   struct op *new = xmalloc (sizeof (struct op) * c);
00964 
00965   memcpy (new, p, c * sizeof (struct op));
00966 
00967   /* Sort all names in table alphabetically.  */
00968   qsort (new, c, sizeof (struct op), (int (*)(const void *, const void *)) func);
00969 
00970   printf ("/* DO NOT EDIT!  -*- buffer-read-only: t -*-\n");
00971   printf ("   This file is automatically generated by z8kgen.  */\n\n");
00972 
00973   printf ("#define ARG_MASK         0x0f\n");
00974 
00975   printf ("#define ARG_SRC          0x01\n");
00976   printf ("#define ARG_DST          0x02\n");
00977 
00978   printf ("#define ARG_RS           0x01\n");
00979   printf ("#define ARG_RD           0x02\n");
00980   printf ("#define ARG_RA           0x03\n");
00981   printf ("#define ARG_RB           0x04\n");
00982   printf ("#define ARG_RR           0x05\n");
00983   printf ("#define ARG_RX           0x06\n");
00984 
00985   printf ("#define ARG_IMM4         0x01\n");
00986   printf ("#define ARG_IMM8         0x02\n");
00987   printf ("#define ARG_IMM16        0x03\n");
00988   printf ("#define ARG_IMM32        0x04\n");
00989   printf ("#define ARG_IMMN         0x05\n");
00990   printf ("#define ARG_IMMNMINUS1   0x05\n");
00991   printf ("#define ARG_IMM_1        0x06\n");
00992   printf ("#define ARG_IMM_2        0x07\n");
00993   printf ("#define ARG_DISP16       0x08\n");
00994   printf ("#define ARG_NIM8         0x09\n");
00995   printf ("#define ARG_IMM2         0x0a\n");
00996   printf ("#define ARG_IMM1OR2      0x0b\n");
00997 
00998   printf ("#define ARG_DISP12       0x0b\n");
00999   printf ("#define ARG_NIM4         0x0c\n");
01000   printf ("#define ARG_DISP8        0x0c\n");
01001   printf ("#define ARG_IMM4M1       0x0d\n");
01002 
01003   printf ("#define CLASS_X          0x10\n");
01004   printf ("#define CLASS_BA         0x20\n");
01005   printf ("#define CLASS_DA         0x30\n");
01006   printf ("#define CLASS_BX         0x40\n");
01007   printf ("#define CLASS_DISP       0x50\n");
01008   printf ("#define CLASS_IMM        0x60\n");
01009   printf ("#define CLASS_CC         0x70\n");
01010   printf ("#define CLASS_CTRL       0x80\n");
01011   printf ("#define CLASS_IGNORE     0x90\n");
01012   printf ("#define CLASS_ADDRESS    0xd0\n");
01013   printf ("#define CLASS_0CCC       0xe0\n");
01014   printf ("#define CLASS_1CCC       0xf0\n");
01015   printf ("#define CLASS_0DISP7    0x100\n");
01016   printf ("#define CLASS_1DISP7    0x200\n");
01017   printf ("#define CLASS_01II      0x300\n");
01018   printf ("#define CLASS_00II      0x400\n");
01019   printf ("#define CLASS_BIT       0x500\n");
01020   printf ("#define CLASS_FLAGS     0x600\n");
01021   printf ("#define CLASS_IR        0x700\n");
01022   printf ("#define CLASS_IRO       0x800\n");
01023   printf ("#define CLASS_DISP8     0x900\n");
01024 
01025   printf ("#define CLASS_BIT_1OR2  0xa00\n");
01026   printf ("#define CLASS_REG       0x7000\n");
01027   printf ("#define CLASS_REG_BYTE  0x2000\n");
01028   printf ("#define CLASS_REG_WORD  0x3000\n");
01029   printf ("#define CLASS_REG_QUAD  0x4000\n");
01030   printf ("#define CLASS_REG_LONG  0x5000\n");
01031   printf ("#define CLASS_REGN0     0x8000\n");
01032   printf ("#define CLASS_PR       0x10000\n");
01033   printf ("#define CLASS_MASK     0x1fff0\n");
01034 
01035   printf ("#define OPC_adc      0\n");
01036   printf ("#define OPC_adcb     1\n");
01037   printf ("#define OPC_add      2\n");
01038   printf ("#define OPC_addb     3\n");
01039   printf ("#define OPC_addl     4\n");
01040   printf ("#define OPC_and      5\n");
01041   printf ("#define OPC_andb     6\n");
01042   printf ("#define OPC_bit      7\n");
01043   printf ("#define OPC_bitb     8\n");
01044   printf ("#define OPC_call     9\n");
01045   printf ("#define OPC_calr    10\n");
01046   printf ("#define OPC_clr     11\n");
01047   printf ("#define OPC_clrb    12\n");
01048   printf ("#define OPC_com     13\n");
01049   printf ("#define OPC_comb    14\n");
01050   printf ("#define OPC_comflg  15\n");
01051   printf ("#define OPC_cp      16\n");
01052   printf ("#define OPC_cpb     17\n");
01053   printf ("#define OPC_cpd     18\n");
01054   printf ("#define OPC_cpdb    19\n");
01055   printf ("#define OPC_cpdr    20\n");
01056   printf ("#define OPC_cpdrb   21\n");
01057   printf ("#define OPC_cpi     22\n");
01058   printf ("#define OPC_cpib    23\n");
01059   printf ("#define OPC_cpir    24\n");
01060   printf ("#define OPC_cpirb   25\n");
01061   printf ("#define OPC_cpl     26\n");
01062   printf ("#define OPC_cpsd    27\n");
01063   printf ("#define OPC_cpsdb   28\n");
01064   printf ("#define OPC_cpsdr   29\n");
01065   printf ("#define OPC_cpsdrb  30\n");
01066   printf ("#define OPC_cpsi    31\n");
01067   printf ("#define OPC_cpsib   32\n");
01068   printf ("#define OPC_cpsir   33\n");
01069   printf ("#define OPC_cpsirb  34\n");
01070   printf ("#define OPC_dab     35\n");
01071   printf ("#define OPC_dbjnz   36\n");
01072   printf ("#define OPC_dec     37\n");
01073   printf ("#define OPC_decb    38\n");
01074   printf ("#define OPC_di      39\n");
01075   printf ("#define OPC_div     40\n");
01076   printf ("#define OPC_divl    41\n");
01077   printf ("#define OPC_djnz    42\n");
01078   printf ("#define OPC_ei      43\n");
01079   printf ("#define OPC_ex      44\n");
01080   printf ("#define OPC_exb     45\n");
01081   printf ("#define OPC_exts    46\n");
01082   printf ("#define OPC_extsb   47\n");
01083   printf ("#define OPC_extsl   48\n");
01084   printf ("#define OPC_halt    49\n");
01085   printf ("#define OPC_in      50\n");
01086   printf ("#define OPC_inb     51\n");
01087   printf ("#define OPC_inc     52\n");
01088   printf ("#define OPC_incb    53\n");
01089   printf ("#define OPC_ind     54\n");
01090   printf ("#define OPC_indb    55\n");
01091   printf ("#define OPC_indr    56\n");
01092   printf ("#define OPC_indrb   57\n");
01093   printf ("#define OPC_ini     58\n");
01094   printf ("#define OPC_inib    59\n");
01095   printf ("#define OPC_inir    60\n");
01096   printf ("#define OPC_inirb   61\n");
01097   printf ("#define OPC_iret    62\n");
01098   printf ("#define OPC_jp      63\n");
01099   printf ("#define OPC_jr      64\n");
01100   printf ("#define OPC_ld      65\n");
01101   printf ("#define OPC_lda     66\n");
01102   printf ("#define OPC_ldar    67\n");
01103   printf ("#define OPC_ldb     68\n");
01104   printf ("#define OPC_ldctl   69\n");
01105   printf ("#define OPC_ldir    70\n");
01106   printf ("#define OPC_ldirb   71\n");
01107   printf ("#define OPC_ldk     72\n");
01108   printf ("#define OPC_ldl     73\n");
01109   printf ("#define OPC_ldm     74\n");
01110   printf ("#define OPC_ldps    75\n");
01111   printf ("#define OPC_ldr     76\n");
01112   printf ("#define OPC_ldrb    77\n");
01113   printf ("#define OPC_ldrl    78\n");
01114   printf ("#define OPC_mbit    79\n");
01115   printf ("#define OPC_mreq    80\n");
01116   printf ("#define OPC_mres    81\n");
01117   printf ("#define OPC_mset    82\n");
01118   printf ("#define OPC_mult    83\n");
01119   printf ("#define OPC_multl   84\n");
01120   printf ("#define OPC_neg     85\n");
01121   printf ("#define OPC_negb    86\n");
01122   printf ("#define OPC_nop     87\n");
01123   printf ("#define OPC_or      88\n");
01124   printf ("#define OPC_orb     89\n");
01125   printf ("#define OPC_otdr    90\n");
01126   printf ("#define OPC_otdrb   91\n");
01127   printf ("#define OPC_otir    92\n");
01128   printf ("#define OPC_otirb   93\n");
01129   printf ("#define OPC_out     94\n");
01130   printf ("#define OPC_outb    95\n");
01131   printf ("#define OPC_outd    96\n");
01132   printf ("#define OPC_outdb   97\n");
01133   printf ("#define OPC_outi    98\n");
01134   printf ("#define OPC_outib   99\n");
01135   printf ("#define OPC_pop    100\n");
01136   printf ("#define OPC_popl   101\n");
01137   printf ("#define OPC_push   102\n");
01138   printf ("#define OPC_pushl  103\n");
01139   printf ("#define OPC_res    104\n");
01140   printf ("#define OPC_resb   105\n");
01141   printf ("#define OPC_resflg 106\n");
01142   printf ("#define OPC_ret    107\n");
01143   printf ("#define OPC_rl     108\n");
01144   printf ("#define OPC_rlb    109\n");
01145   printf ("#define OPC_rlc    110\n");
01146   printf ("#define OPC_rlcb   111\n");
01147   printf ("#define OPC_rldb   112\n");
01148   printf ("#define OPC_rr     113\n");
01149   printf ("#define OPC_rrb    114\n");
01150   printf ("#define OPC_rrc    115\n");
01151   printf ("#define OPC_rrcb   116\n");
01152   printf ("#define OPC_rrdb   117\n");
01153   printf ("#define OPC_sbc    118\n");
01154   printf ("#define OPC_sbcb   119\n");
01155   printf ("#define OPC_sda    120\n");
01156   printf ("#define OPC_sdab   121\n");
01157   printf ("#define OPC_sdal   122\n");
01158   printf ("#define OPC_sdl    123\n");
01159   printf ("#define OPC_sdlb   124\n");
01160   printf ("#define OPC_sdll   125\n");
01161   printf ("#define OPC_set    126\n");
01162   printf ("#define OPC_setb   127\n");
01163   printf ("#define OPC_setflg 128\n");
01164   printf ("#define OPC_sin    129\n");
01165   printf ("#define OPC_sinb   130\n");
01166   printf ("#define OPC_sind   131\n");
01167   printf ("#define OPC_sindb  132\n");
01168   printf ("#define OPC_sindr  133\n");
01169   printf ("#define OPC_sindrb 134\n");
01170   printf ("#define OPC_sini   135\n");
01171   printf ("#define OPC_sinib  136\n");
01172   printf ("#define OPC_sinir  137\n");
01173   printf ("#define OPC_sinirb 138\n");
01174   printf ("#define OPC_sla    139\n");
01175   printf ("#define OPC_slab   140\n");
01176   printf ("#define OPC_slal   141\n");
01177   printf ("#define OPC_sll    142\n");
01178   printf ("#define OPC_sllb   143\n");
01179   printf ("#define OPC_slll   144\n");
01180   printf ("#define OPC_sotdr  145\n");
01181   printf ("#define OPC_sotdrb 146\n");
01182   printf ("#define OPC_sotir  147\n");
01183   printf ("#define OPC_sotirb 148\n");
01184   printf ("#define OPC_sout   149\n");
01185   printf ("#define OPC_soutb  150\n");
01186   printf ("#define OPC_soutd  151\n");
01187   printf ("#define OPC_soutdb 152\n");
01188   printf ("#define OPC_souti  153\n");
01189   printf ("#define OPC_soutib 154\n");
01190   printf ("#define OPC_sra    155\n");
01191   printf ("#define OPC_srab   156\n");
01192   printf ("#define OPC_sral   157\n");
01193   printf ("#define OPC_srl    158\n");
01194   printf ("#define OPC_srlb   159\n");
01195   printf ("#define OPC_srll   160\n");
01196   printf ("#define OPC_sub    161\n");
01197   printf ("#define OPC_subb   162\n");
01198   printf ("#define OPC_subl   163\n");
01199   printf ("#define OPC_tcc    164\n");
01200   printf ("#define OPC_tccb   165\n");
01201   printf ("#define OPC_test   166\n");
01202   printf ("#define OPC_testb  167\n");
01203   printf ("#define OPC_testl  168\n");
01204   printf ("#define OPC_trdb   169\n");
01205   printf ("#define OPC_trdrb  170\n");
01206   printf ("#define OPC_trib   171\n");
01207   printf ("#define OPC_trirb  172\n");
01208   printf ("#define OPC_trtdrb 173\n");
01209   printf ("#define OPC_trtib  174\n");
01210   printf ("#define OPC_trtirb 175\n");
01211   printf ("#define OPC_trtrb  176\n");
01212   printf ("#define OPC_tset   177\n");
01213   printf ("#define OPC_tsetb  178\n");
01214   printf ("#define OPC_xor    179\n");
01215   printf ("#define OPC_xorb   180\n");
01216 
01217   printf ("#define OPC_ldd    181\n");
01218   printf ("#define OPC_lddb   182\n");
01219   printf ("#define OPC_lddr   183\n");
01220   printf ("#define OPC_lddrb  184\n");
01221   printf ("#define OPC_ldi    185\n");
01222   printf ("#define OPC_ldib   186\n");
01223   printf ("#define OPC_sc     187\n");
01224   printf ("#define OPC_bpt    188\n");
01225   printf ("#define OPC_ext0e  188\n");
01226   printf ("#define OPC_ext0f  188\n");
01227   printf ("#define OPC_ext8e  188\n");
01228   printf ("#define OPC_ext8f  188\n");
01229   printf ("#define OPC_rsvd36 188\n");
01230   printf ("#define OPC_rsvd38 188\n");
01231   printf ("#define OPC_rsvd78 188\n");
01232   printf ("#define OPC_rsvd7e 188\n");
01233   printf ("#define OPC_rsvd9d 188\n");
01234   printf ("#define OPC_rsvd9f 188\n");
01235   printf ("#define OPC_rsvdb9 188\n");
01236   printf ("#define OPC_rsvdbf 188\n");
01237   printf ("#define OPC_ldctlb 189\n");
01238   printf ("#define OPC_trtdb  190\n");
01239   printf ("#define OPC_brk    191\n");
01240 #if 0
01241   for (i = 0; toks[i].token; i++)
01242     printf ("#define %s\t0x%x\n", toks[i].token, i * 16);
01243 #endif
01244   printf ("\ntypedef struct {\n");
01245 
01246   printf ("#ifdef NICENAMES\n");
01247   printf ("  const char *nicename;\n");
01248   printf ("  int type;\n");
01249   printf ("  int cycles;\n");
01250   printf ("  int flags;\n");
01251   printf ("#endif\n");
01252   printf ("  const char *name;\n");
01253   printf ("  unsigned char opcode;\n");
01254   printf ("  void (*func) (void);\n");
01255   printf ("  unsigned int arg_info[4];\n");
01256   printf ("  unsigned int byte_info[%d];\n", BYTE_INFO_LEN);
01257   printf ("  int noperands;\n");
01258   printf ("  int length;\n");
01259   printf ("  int idx;\n");
01260   printf ("} opcode_entry_type;\n\n");
01261   printf ("#ifdef DEFINE_TABLE\n");
01262   printf ("const opcode_entry_type z8k_table[] = {\n");
01263 
01264   while (new->flags && new->flags[0])
01265     {
01266       int nargs;
01267       int length;
01268 
01269       printf ("\n/* %s *** %s */\n", new->bits, new->name);
01270       printf ("{\n");
01271 
01272       printf ("#ifdef NICENAMES\n");
01273       printf ("\"%s\",%d,%d,", new->name, new->type, new->cycles);
01274       {
01275        int answer = 0;
01276        char *p = new->flags;
01277 
01278        while (*p)
01279          {
01280            answer <<= 1;
01281 
01282            if (*p != '-')
01283              answer |= 1;
01284            p++;
01285          }
01286        printf ("0x%02x,\n", answer);
01287       }
01288 
01289       printf ("#endif\n");
01290 
01291       nargs = chewname (&new->name);
01292 
01293       printf ("\n\t");
01294       chewbits (new->bits, &length);
01295       length /= 2;
01296       if (length & 1)
01297        abort();
01298 
01299       if (strcmp (oldname, new->name) != 0)
01300        idx++;
01301       printf (",%d,%d,%d", nargs, length, idx);
01302       oldname = new->name;
01303       printf ("},\n");
01304       new++;
01305     }
01306   printf ("\n/* end marker */\n");
01307   printf ("{\n#ifdef NICENAMES\nNULL,0,0,\n0,\n#endif\n");
01308   printf ("NULL,0,0,{0,0,0,0},{0,0,0,0,0,0,0,0,0,0},0,0,0}\n};\n");
01309   printf ("#endif\n");
01310 }
01311 
01312 int
01313 main (int ac, char **av)
01314 {
01315   struct op *p = opt;
01316 
01317   if (ac == 2 && strcmp (av[1], "-t") == 0)
01318     {
01319       internal ();
01320     }
01321   else if (ac == 2 && strcmp (av[1], "-h") == 0)
01322     {
01323       while (p->name)
01324        {
01325          printf ("%-25s\t%s\n", p->name, p->bits);
01326          p++;
01327        }
01328     }
01329 
01330   else if (ac == 2 && strcmp (av[1], "-a") == 0)
01331     {
01332       gas ();
01333     }
01334   else
01335     {
01336       printf ("Usage: %s -t\n", av[0]);
01337       printf ("-t : generate new internal table\n");
01338       printf ("-a : generate new table for gas\n");
01339       printf ("-h : generate new table for humans\n");
01340     }
01341   return 0;
01342 }