Back to index

cell-binutils  2.17cvs20070401
z80-dis.c
Go to the documentation of this file.
00001 /* Print Z80 and R800 instructions
00002    Copyright 2005 Free Software Foundation, Inc.
00003    Contributed by Arnold Metselaar <arnold_m@operamail.com>
00004 
00005    This file 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,
00018    MA 02110-1301, USA.  */
00019 
00020 #include "sysdep.h"
00021 #include "dis-asm.h"
00022 #include <stdio.h>
00023 
00024 struct buffer
00025 {
00026   bfd_vma base;
00027   int n_fetch;
00028   int n_used;
00029   signed char data[4];
00030 } ;
00031 
00032 typedef int (*func)(struct buffer *, disassemble_info *, char *);
00033 
00034 struct tab_elt
00035 {
00036   unsigned char val;
00037   unsigned char mask;
00038   func          fp;
00039   char *        text;
00040 } ;
00041 
00042 #define TXTSIZ 24
00043 /* Names of 16-bit registers.  */
00044 static char * rr_str[] = { "bc", "de", "hl", "sp" };
00045 /* Names of 8-bit registers.  */
00046 static char * r_str[]  = { "b", "c", "d", "e", "h", "l", "(hl)", "a" };
00047 /* Texts for condition codes.  */
00048 static char * cc_str[] = { "nz", "z", "nc", "c", "po", "pe", "p", "m" };
00049 /* Instruction names for 8-bit arithmetic, operand "a" is often implicit */
00050 static char * arit_str[] =
00051 {
00052   "add a,", "adc a,", "sub ", "sbc a,", "and ", "xor ", "or ", "cp "
00053 } ;
00054 
00055 static int
00056 fetch_data (struct buffer *buf, disassemble_info * info, int n)
00057 {
00058   int r;
00059 
00060   if (buf->n_fetch + n > 4)
00061     abort ();
00062 
00063   r = info->read_memory_func (buf->base + buf->n_fetch,
00064                            (unsigned char*) buf->data + buf->n_fetch,
00065                            n, info);
00066   if (r == 0)
00067     buf->n_fetch += n;
00068   return !r;
00069 }
00070 
00071 static int
00072 prt (struct buffer *buf, disassemble_info * info, char *txt)
00073 {
00074   info->fprintf_func (info->stream, "%s", txt);
00075   buf->n_used = buf->n_fetch;
00076   return 1;
00077 }
00078 
00079 static int
00080 prt_e (struct buffer *buf, disassemble_info * info, char *txt)
00081 {
00082   char e;
00083   int target_addr;
00084 
00085   if (fetch_data (buf, info, 1))
00086     {
00087       e = buf->data[1];
00088       target_addr = (buf->base + 2 + e) & 0xffff;
00089       buf->n_used = buf->n_fetch;
00090       info->fprintf_func (info->stream, "%s0x%04x", txt, target_addr);
00091     }
00092   else
00093     buf->n_used = -1;
00094 
00095   return buf->n_used;
00096 }
00097 
00098 static int
00099 jr_cc (struct buffer *buf, disassemble_info * info, char *txt)
00100 {
00101   char mytxt[TXTSIZ];
00102 
00103   snprintf (mytxt, TXTSIZ, txt, cc_str[(buf->data[0] >> 3) & 3]);
00104   return prt_e (buf, info, mytxt);
00105 }
00106 
00107 static int
00108 prt_nn (struct buffer *buf, disassemble_info * info, char *txt)
00109 {
00110   int nn;
00111   unsigned char *p;
00112 
00113   p = (unsigned char*) buf->data + buf->n_fetch;
00114   if (fetch_data (buf, info, 2))
00115     {
00116       nn = p[0] + (p[1] << 8);
00117       info->fprintf_func (info->stream, txt, nn);
00118       buf->n_used = buf->n_fetch;
00119     }
00120   else
00121     buf->n_used = -1;
00122   return buf->n_used;
00123 }
00124 
00125 static int
00126 prt_rr_nn (struct buffer *buf, disassemble_info * info, char *txt)
00127 {
00128   char mytxt[TXTSIZ];
00129 
00130   snprintf (mytxt, TXTSIZ, txt, rr_str[(buf->data[0] >> 4) & 3]);
00131   return prt_nn (buf, info, mytxt);
00132 }
00133 
00134 static int
00135 prt_rr (struct buffer *buf, disassemble_info * info, char *txt)
00136 {
00137   info->fprintf_func (info->stream, "%s%s", txt,
00138                     rr_str[(buf->data[buf->n_fetch - 1] >> 4) & 3]);
00139   buf->n_used = buf->n_fetch;
00140   return buf->n_used;
00141 }
00142 
00143 static int
00144 prt_n (struct buffer *buf, disassemble_info * info, char *txt)
00145 {
00146   int n;
00147   unsigned char *p;
00148 
00149   p = (unsigned char*) buf->data + buf->n_fetch;
00150 
00151   if (fetch_data (buf, info, 1))
00152     {
00153       n = p[0];
00154       info->fprintf_func (info->stream, txt, n);
00155       buf->n_used = buf->n_fetch;
00156     }
00157   else
00158     buf->n_used = -1;
00159 
00160   return buf->n_used;
00161 }
00162 
00163 static int
00164 ld_r_n (struct buffer *buf, disassemble_info * info, char *txt)
00165 {
00166   char mytxt[TXTSIZ];
00167 
00168   snprintf (mytxt, TXTSIZ, txt, r_str[(buf->data[0] >> 3) & 7]);
00169   return prt_n (buf, info, mytxt);
00170 }
00171 
00172 static int
00173 prt_r (struct buffer *buf, disassemble_info * info, char *txt)
00174 {
00175   info->fprintf_func (info->stream, txt,
00176                     r_str[(buf->data[buf->n_fetch - 1] >> 3) & 7]);
00177   buf->n_used = buf->n_fetch;
00178   return buf->n_used;
00179 }
00180 
00181 static int
00182 ld_r_r (struct buffer *buf, disassemble_info * info, char *txt)
00183 {
00184   info->fprintf_func (info->stream, txt,
00185                     r_str[(buf->data[buf->n_fetch - 1] >> 3) & 7],
00186                     r_str[buf->data[buf->n_fetch - 1] & 7]);
00187   buf->n_used = buf->n_fetch;
00188   return buf->n_used;
00189 }
00190 
00191 static int
00192 arit_r (struct buffer *buf, disassemble_info * info, char *txt)
00193 {
00194   info->fprintf_func (info->stream, txt,
00195                     arit_str[(buf->data[buf->n_fetch - 1] >> 3) & 7],
00196                     r_str[buf->data[buf->n_fetch - 1] & 7]);
00197   buf->n_used = buf->n_fetch;
00198   return buf->n_used;
00199 }
00200 
00201 static int
00202 prt_cc (struct buffer *buf, disassemble_info * info, char *txt)
00203 {
00204   info->fprintf_func (info->stream, "%s%s", txt,
00205                     cc_str[(buf->data[0] >> 3) & 7]);
00206   buf->n_used = buf->n_fetch;
00207   return buf->n_used;
00208 }
00209 
00210 static int
00211 pop_rr (struct buffer *buf, disassemble_info * info, char *txt)
00212 {
00213   static char *rr_stack[] = { "bc","de","hl","af"};
00214 
00215   info->fprintf_func (info->stream, "%s %s", txt,
00216                     rr_stack[(buf->data[0] >> 4) & 3]);
00217   buf->n_used = buf->n_fetch;
00218   return buf->n_used;
00219 }
00220 
00221 
00222 static int
00223 jp_cc_nn (struct buffer *buf, disassemble_info * info, char *txt)
00224 {
00225   char mytxt[TXTSIZ];
00226 
00227   snprintf (mytxt,TXTSIZ,
00228            "%s%s,0x%%04x", txt, cc_str[(buf->data[0] >> 3) & 7]);
00229   return prt_nn (buf, info, mytxt);
00230 }
00231 
00232 static int
00233 arit_n (struct buffer *buf, disassemble_info * info, char *txt)
00234 {
00235   char mytxt[TXTSIZ];
00236 
00237   snprintf (mytxt,TXTSIZ, txt, arit_str[(buf->data[0] >> 3) & 7]);
00238   return prt_n (buf, info, mytxt);
00239 }
00240 
00241 static int
00242 rst (struct buffer *buf, disassemble_info * info, char *txt)
00243 {
00244   info->fprintf_func (info->stream, txt, buf->data[0] & 0x38);
00245   buf->n_used = buf->n_fetch;
00246   return buf->n_used;
00247 }
00248 
00249 
00250 static int
00251 cis (struct buffer *buf, disassemble_info * info, char *txt ATTRIBUTE_UNUSED)
00252 {
00253   static char * opar[] = { "ld", "cp", "in", "out" };
00254   char * op;
00255   char c;
00256 
00257   c = buf->data[1];
00258   op = ((0x13 & c) == 0x13) ? "ot" : (opar[c & 3]);
00259   info->fprintf_func (info->stream,
00260                     "%s%c%s", op,
00261                     (c & 0x08) ? 'd' : 'i',
00262                     (c & 0x10) ? "r" : "");
00263   buf->n_used = 2;
00264   return buf->n_used;
00265 }
00266 
00267 static int
00268 dump (struct buffer *buf, disassemble_info * info, char *txt)
00269 {
00270   int i;
00271 
00272   info->fprintf_func (info->stream, "defb ");
00273   for (i = 0; txt[i]; ++i)
00274     info->fprintf_func (info->stream, i ? ", 0x%02x" : "0x%02x",
00275                      (unsigned char) buf->data[i]);
00276   buf->n_used = i;
00277   return buf->n_used;
00278 }
00279 
00280 /* Table to disassemble machine codes with prefix 0xED.  */
00281 struct tab_elt opc_ed[] =
00282 {
00283   { 0x70, 0xFF, prt, "in f,(c)" },
00284   { 0x70, 0xFF, dump, "xx" },
00285   { 0x40, 0xC7, prt_r, "in %s,(c)" },
00286   { 0x71, 0xFF, prt, "out (c),0" },
00287   { 0x70, 0xFF, dump, "xx" },
00288   { 0x41, 0xC7, prt_r, "out (c),%s" },
00289   { 0x42, 0xCF, prt_rr, "sbc hl," },
00290   { 0x43, 0xCF, prt_rr_nn, "ld (0x%%04x),%s" },
00291   { 0x44, 0xFF, prt, "neg" },
00292   { 0x45, 0xFF, prt, "retn" },
00293   { 0x46, 0xFF, prt, "im 0" },
00294   { 0x47, 0xFF, prt, "ld i,a" },
00295   { 0x4A, 0xCF, prt_rr, "adc hl," },
00296   { 0x4B, 0xCF, prt_rr_nn, "ld %s,(0x%%04x)" },
00297   { 0x4D, 0xFF, prt, "reti" },
00298   { 0x56, 0xFF, prt, "im 1" },
00299   { 0x57, 0xFF, prt, "ld a,i" },
00300   { 0x5E, 0xFF, prt, "im 2" },
00301   { 0x67, 0xFF, prt, "rrd" },
00302   { 0x6F, 0xFF, prt, "rld" },
00303   { 0xA0, 0xE4, cis, "" },
00304   { 0xC3, 0xFF, prt, "muluw hl,bc" },
00305   { 0xC5, 0xE7, prt_r, "mulub a,%s" },
00306   { 0xF3, 0xFF, prt, "muluw hl,sp" },
00307   { 0x00, 0x00, dump, "xx" }
00308 };
00309 
00310 static int
00311 pref_ed (struct buffer * buf, disassemble_info * info, 
00312         char* txt ATTRIBUTE_UNUSED)
00313 {
00314   struct tab_elt *p;
00315 
00316   if (fetch_data(buf, info, 1))
00317     {
00318       for (p = opc_ed; p->val != (buf->data[1] & p->mask); ++p)
00319        ;
00320       p->fp (buf, info, p->text);
00321     }
00322   else
00323     buf->n_used = -1;
00324 
00325   return buf->n_used;
00326 }
00327 
00328 /* Instruction names for the instructions addressing single bits.  */
00329 static char *cb1_str[] = { "", "bit", "res", "set"};
00330 /* Instruction names for shifts and rotates.  */
00331 static char *cb2_str[] =
00332 {
00333   "rlc", "rrc", "rl", "rr", "sla", "sra", "sli", "srl"
00334 };
00335 
00336 static int
00337 pref_cb (struct buffer * buf, disassemble_info * info,
00338         char* txt ATTRIBUTE_UNUSED)
00339 {
00340   if (fetch_data (buf, info, 1))
00341     {
00342       buf->n_used = 2;
00343       if ((buf->data[1] & 0xc0) == 0)
00344        info->fprintf_func (info->stream, "%s %s",
00345                          cb2_str[(buf->data[1] >> 3) & 7],
00346                          r_str[buf->data[1] & 7]);
00347       else
00348        info->fprintf_func (info->stream, "%s %d,%s",
00349                          cb1_str[(buf->data[1] >> 6) & 3],
00350                          (buf->data[1] >> 3) & 7,
00351                          r_str[buf->data[1] & 7]);
00352     }
00353   else
00354     buf->n_used = -1;
00355 
00356   return buf->n_used;
00357 }
00358 
00359 static int
00360 addvv (struct buffer * buf, disassemble_info * info, char* txt)
00361 {
00362   info->fprintf_func (info->stream, "add %s,%s", txt, txt);
00363 
00364   return buf->n_used = buf->n_fetch;
00365 }
00366 
00367 static int
00368 ld_v_v (struct buffer * buf, disassemble_info * info, char* txt)
00369 {
00370   char mytxt[TXTSIZ];
00371 
00372   snprintf (mytxt, TXTSIZ, "ld %s%%s,%s%%s", txt, txt);
00373   return ld_r_r (buf, info, mytxt);
00374 }
00375 
00376 static int
00377 prt_d (struct buffer *buf, disassemble_info * info, char *txt)
00378 {
00379   int d;
00380   signed char *p;
00381 
00382   p = buf->data + buf->n_fetch;
00383 
00384   if (fetch_data (buf, info, 1))
00385     {
00386       d = p[0];
00387       info->fprintf_func (info->stream, txt, d);
00388       buf->n_used = buf->n_fetch;
00389     }
00390   else
00391     buf->n_used = -1;
00392 
00393   return buf->n_used;
00394 }
00395 
00396 static int
00397 prt_d_n (struct buffer *buf, disassemble_info * info, char *txt)
00398 {
00399   char mytxt[TXTSIZ];
00400   int d;
00401   signed char *p;
00402 
00403   p = buf->data + buf->n_fetch;
00404 
00405   if (fetch_data (buf, info, 1))
00406     {
00407       d = p[0];
00408       snprintf (mytxt, TXTSIZ, txt, d);
00409       return prt_n (buf, info, mytxt);
00410     }
00411   else
00412     buf->n_used = -1;
00413 
00414   return buf->n_used;
00415 }
00416 
00417 static int
00418 arit_d (struct buffer *buf, disassemble_info * info, char *txt)
00419 {
00420   char mytxt[TXTSIZ];
00421   signed char c;
00422 
00423   c = buf->data[buf->n_fetch - 1];
00424   snprintf (mytxt, TXTSIZ, txt, arit_str[(c >> 3) & 7]);
00425   return prt_d (buf, info, mytxt);
00426 }
00427 
00428 static int
00429 ld_r_d (struct buffer *buf, disassemble_info * info, char *txt)
00430 {
00431   char mytxt[TXTSIZ];
00432   signed char c;
00433 
00434   c = buf->data[buf->n_fetch - 1];
00435   snprintf (mytxt, TXTSIZ, txt, r_str[(c >> 3) & 7]);
00436   return prt_d (buf, info, mytxt);
00437 }
00438 
00439 static int
00440 ld_d_r(struct buffer *buf, disassemble_info * info, char *txt)
00441 {
00442   char mytxt[TXTSIZ];
00443   signed char c;
00444 
00445   c = buf->data[buf->n_fetch - 1];
00446   snprintf (mytxt, TXTSIZ, txt, r_str[c & 7]);
00447   return prt_d (buf, info, mytxt);
00448 }
00449 
00450 static int
00451 pref_xd_cb (struct buffer * buf, disassemble_info * info, char* txt)
00452 {
00453   if (fetch_data (buf, info, 2))
00454     {
00455       int d;
00456       char arg[TXTSIZ];
00457       signed char *p;
00458 
00459       buf->n_used = 4;
00460       p = buf->data;
00461       d = p[2];
00462 
00463       if (((p[3] & 0xC0) == 0x40) || ((p[3] & 7) == 0x06))
00464        snprintf (arg, TXTSIZ, "(%s%+d)", txt, d);
00465       else
00466        snprintf (arg, TXTSIZ, "(%s%+d),%s", txt, d, r_str[p[3] & 7]);
00467 
00468       if ((p[3] & 0xc0) == 0)
00469        info->fprintf_func (info->stream, "%s %s",
00470                          cb2_str[(buf->data[3] >> 3) & 7],
00471                          arg);
00472       else
00473        info->fprintf_func (info->stream, "%s %d,%s",
00474                          cb1_str[(buf->data[3] >> 6) & 3],
00475                          (buf->data[3] >> 3) & 7,
00476                          arg);
00477     }
00478   else
00479     buf->n_used = -1;
00480 
00481   return buf->n_used;
00482 }
00483 
00484 /* Table to disassemble machine codes with prefix 0xDD or 0xFD.  */
00485 static struct tab_elt opc_ind[] =
00486 {
00487   { 0x24, 0xF7, prt_r, "inc %s%%s" },
00488   { 0x25, 0xF7, prt_r, "dec %s%%s" },
00489   { 0x26, 0xF7, ld_r_n, "ld %s%%s,0x%%%%02x" },
00490   { 0x21, 0xFF, prt_nn, "ld %s,0x%%04x" },
00491   { 0x22, 0xFF, prt_nn, "ld (0x%%04x),%s" },
00492   { 0x2A, 0xFF, prt_nn, "ld %s,(0x%%04x)" },
00493   { 0x23, 0xFF, prt, "inc %s" },
00494   { 0x2B, 0xFF, prt, "dec %s" },
00495   { 0x29, 0xFF, addvv, "%s" },
00496   { 0x09, 0xCF, prt_rr, "add %s," },
00497   { 0x34, 0xFF, prt_d, "inc (%s%%+d)" },
00498   { 0x35, 0xFF, prt_d, "dec (%s%%+d)" },
00499   { 0x36, 0xFF, prt_d_n, "ld (%s%%+d),0x%%%%02x" },
00500 
00501   { 0x76, 0xFF, dump, "h" },
00502   { 0x46, 0xC7, ld_r_d, "ld %%s,(%s%%%%+d)" },
00503   { 0x70, 0xF8, ld_d_r, "ld (%s%%%%+d),%%s" },
00504   { 0x64, 0xF6, ld_v_v, "%s" },
00505   { 0x60, 0xF0, ld_r_r, "ld %s%%s,%%s" },
00506   { 0x44, 0xC6, ld_r_r, "ld %%s,%s%%s" },
00507 
00508   { 0x86, 0xC7, arit_d, "%%s(%s%%%%+d)" },
00509   { 0x84, 0xC6, arit_r, "%%s%s%%s" },
00510 
00511   { 0xE1, 0xFF, prt, "pop %s" },
00512   { 0xE5, 0xFF, prt, "push %s" },
00513   { 0xCB, 0xFF, pref_xd_cb, "%s" },
00514   { 0xE3, 0xFF, prt, "ex (sp),%s" },
00515   { 0xE9, 0xFF, prt, "jp (%s)" },
00516   { 0xF9, 0xFF, prt, "ld sp,%s" },
00517   { 0x00, 0x00, dump, "?" },
00518 } ;
00519 
00520 static int
00521 pref_ind (struct buffer * buf, disassemble_info * info, char* txt)
00522 {
00523   if (fetch_data (buf, info, 1))
00524     {
00525       char mytxt[TXTSIZ];
00526       struct tab_elt *p;
00527 
00528       for (p = opc_ind; p->val != (buf->data[1] & p->mask); ++p)
00529        ;
00530       snprintf (mytxt, TXTSIZ, p->text, txt);
00531       p->fp (buf, info, mytxt);
00532     }
00533   else
00534     buf->n_used = -1;
00535 
00536   return buf->n_used;
00537 }
00538 
00539 /* Table to disassemble machine codes without prefix.  */
00540 static struct tab_elt opc_main[] =
00541 {
00542   { 0x00, 0xFF, prt, "nop" },
00543   { 0x01, 0xCF, prt_rr_nn, "ld %s,0x%%04x" },
00544   { 0x02, 0xFF, prt, "ld (bc),a" },
00545   { 0x03, 0xCF, prt_rr, "inc " },
00546   { 0x04, 0xC7, prt_r, "inc %s" },
00547   { 0x05, 0xC7, prt_r, "dec %s" },
00548   { 0x06, 0xC7, ld_r_n, "ld %s,0x%%02x" },
00549   { 0x07, 0xFF, prt, "rlca" },
00550   { 0x08, 0xFF, prt, "ex af,af'" },
00551   { 0x09, 0xCF, prt_rr, "add hl," },
00552   { 0x0A, 0xFF, prt, "ld a,(bc)" },
00553   { 0x0B, 0xCF, prt_rr, "dec " },
00554   { 0x0F, 0xFF, prt, "rrca" },
00555   { 0x10, 0xFF, prt_e, "djnz " },
00556   { 0x12, 0xFF, prt, "ld (de),a" },
00557   { 0x17, 0xFF, prt, "rla" },
00558   { 0x18, 0xFF, prt_e, "jr "},
00559   { 0x1A, 0xFF, prt, "ld a,(de)" },
00560   { 0x1F, 0xFF, prt, "rra" },
00561   { 0x20, 0xE7, jr_cc, "jr %s,"},
00562   { 0x22, 0xFF, prt_nn, "ld (0x%04x),hl" },
00563   { 0x27, 0xFF, prt, "daa"},
00564   { 0x2A, 0xFF, prt_nn, "ld hl,(0x%04x)" },
00565   { 0x2F, 0xFF, prt, "cpl" },
00566   { 0x32, 0xFF, prt_nn, "ld (0x%04x),a" },
00567   { 0x37, 0xFF, prt, "scf" },
00568   { 0x3A, 0xFF, prt_nn, "ld a,(0x%04x)" },
00569   { 0x3F, 0xFF, prt, "ccf" },
00570 
00571   { 0x76, 0xFF, prt, "halt" },
00572   { 0x40, 0xC0, ld_r_r, "ld %s,%s"},
00573 
00574   { 0x80, 0xC0, arit_r, "%s%s" },
00575 
00576   { 0xC0, 0xC7, prt_cc, "ret " },
00577   { 0xC1, 0xCF, pop_rr, "pop" },
00578   { 0xC2, 0xC7, jp_cc_nn, "jp " },
00579   { 0xC3, 0xFF, prt_nn, "jp 0x%04x" },
00580   { 0xC4, 0xC7, jp_cc_nn, "call " },
00581   { 0xC5, 0xCF, pop_rr, "push" },
00582   { 0xC6, 0xC7, arit_n, "%s0x%%02x" },
00583   { 0xC7, 0xC7, rst, "rst 0x%02x" },
00584   { 0xC9, 0xFF, prt, "ret" },
00585   { 0xCB, 0xFF, pref_cb, "" },
00586   { 0xCD, 0xFF, prt_nn, "call 0x%04x" },
00587   { 0xD3, 0xFF, prt_n, "out (0x%02x),a" },
00588   { 0xD9, 0xFF, prt, "exx" },
00589   { 0xDB, 0xFF, prt_n, "in a,(0x%02x)" },
00590   { 0xDD, 0xFF, pref_ind, "ix" },
00591   { 0xE3, 0xFF, prt, "ex (sp),hl" },
00592   { 0xE9, 0xFF, prt, "jp (hl)" },
00593   { 0xEB, 0xFF, prt, "ex de,hl" },
00594   { 0xED, 0xFF, pref_ed, ""},
00595   { 0xF3, 0xFF, prt, "di" },
00596   { 0xF9, 0xFF, prt, "ld sp,hl" },
00597   { 0xFB, 0xFF, prt, "ei" },
00598   { 0xFD, 0xFF, pref_ind, "iy" },
00599   { 0x00, 0x00, prt, "????" },
00600 } ;
00601 
00602 int
00603 print_insn_z80 (bfd_vma addr, disassemble_info * info)
00604 {
00605   struct buffer buf;
00606   struct tab_elt *p;
00607 
00608   buf.base = addr;
00609   buf.n_fetch = 0;
00610   buf.n_used = 0;
00611 
00612   if (! fetch_data (& buf, info, 1))
00613     return -1;
00614 
00615   for (p = opc_main; p->val != (buf.data[0] & p->mask); ++p)
00616     ;
00617   p->fp (& buf, info, p->text);
00618 
00619   return buf.n_used;
00620 }