hppa/disassembler.m

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2000-2001, The University of Queensland
00003  *
00004  * See the file "LICENSE.TERMS" for information on usage and
00005  * redistribution of this file, and for a DISCLAIMER OF ALL
00006  * WARRANTIES.
00007  *
00008  */
00009 
00010 /*==============================================================================
00011  * FILE:     disassembler.m
00012  * OVERVIEW: Matcher file for a stand alone disassembler tool
00013  *============================================================================*/
00014 
00015 /*
00016  * $Revision: 1.1 $
00017  *
00018  * Simon Long 2000.11.30
00019  * 03 May 01 - Mike: Added constructor names (use -c); don't truncate opcode
00020  *              names to 3 chars
00021  * 08 May 01 - Mike: Many mods to work with Cristina's disassembler model
00022  * 09 May 01 - Mike: %ld -> %d (prevents pages of warnings) with gcc 2.95
00023  * 18 Jun 01 - Mike: Added floating point instructions
00024  * 28 Jun 01 - Mike: Major rewrite of integer loads and stores for 1.1 syntax
00025  * 20 Jul 01 - Mike: Some necessary changes due to Simon's revisions in .spec
00026  * 23 Jul 01 - Simon: Continued the changes due to revisions in .spec; use
00027  *              macros to simplify code; separate building of the opcode name
00028  *              (including completers) using apre and astr char ptrs
00029  * 24 Jul 01 - Simon: bug fixes (e.g. LDO, etc)
00030  * 27 Jul 01 - Mike: Display floating registers greater than 32 as frXXR
00031  * 06 Aug 01 - Mike: Added add[i]b_all; fixed MTCTL (no ct_06 field now)
00032  * 07 Aug 01 - Mike: Reinstated dis_c_addr for c_s_addr_m[ab] (fixes "STB,ma")
00033  * 07 Aug 01 - Simon: dis_addr() gone completely - [addr] => [xd,s,b]
00034  * 20 Aug 01 - Mike: Fixed the CONS() for floating point loads and stores
00035  * 20 Aug 01 - Simon: Fixed floating point load/store with ,ma or ,mb
00036  */
00037 
00038 
00039 
00040 #include "global.h"
00041 #include "decoder.h"
00042 #include "BinaryFile.h"
00043 
00044 #include "hppa-names.h"
00045 
00046 // globals
00047 extern char _assembly;
00048 char aprefix;
00049 char adata;
00050 char* apre;
00051 char* astr;
00052 char *cmpltsep = ".";       // ??
00053 
00054 // Prototypes
00055 const char* GetSym(unsigned pc);
00056 const char* GetReloc(unsigned pc);
00057 
00058 
00059 #define ANAME       apre += sprintf( apre, "%s", name );
00060 //#define APREF(x)    apre += sprintf( apre, "%s", x );
00061 //#define AARGs(x)    astr += sprintf( astr, "%s", x );
00062 //#define AARGd(x)    astr += sprintf( astr, "%d", x );
00063 //#define AARGf(f, x) astr += sprintf( astr, " ## f ## ", x );
00064 //#define Acom        astr += sprintf( astr, "," );
00065 #define CONS(x)     strcat(constrName, x);
00066 #define IGNORE(x)   not_used(*(int*)&x);
00067 
00068 // The below is used to quelch annoying "variable not used" warnings
00069 void not_used(int unwanted)
00070 {
00071     unwanted = 0;
00072 }
00073 
00074 DWord getDword (unsigned lc)
00075 /* get4Bytes - returns next 4-Byte from image pointed to by lc.
00076    Fetch in a big-endian manner  */
00077 {
00078     return
00079       (DWord)
00080       ((((((
00081           *(Byte *)lc << 8
00082       ) + *(Byte *)(lc+1)) << 8
00083       ) + *(Byte *)(lc+2)) << 8
00084       ) + *(Byte *)(lc+3));
00085 }
00086 
00087 static char killBuffer;
00088 
00089 // Find and kill any dots in the opcode name (and all chars thereafter)
00090 char* killDot(char* str)
00091 {
00092     strcpy(killBuffer, str);
00093     char* p = strchr(killBuffer, '.');
00094     if (p) *p = '\0';
00095     return killBuffer;
00096 }
00097 
00098 static char shexBuffer;
00099 
00100 char* signedHex(int disp)
00101 {
00102     if (disp < 0)
00103         sprintf(shexBuffer, "-0x%x", -disp);
00104     else
00105         sprintf(shexBuffer, "0x%x", disp);
00106     return shexBuffer;
00107 }
00108 
00109 // This function returns 0 or 8; the 8 is to access the last half of arrays
00110 // of conditions (e.g. CMPIBF, or the "f" bit of ariths)
00111 int dis_c_c_n(ADDRESS hostpc)
00112 {
00113     int result = 0;
00114     match hostpc to
00115       | c_c_nonneg() => { result = 0; }
00116       | c_c_neg() =>    { result = 8; }
00117     endmatch
00118     return result;
00119 }
00120 
00121 void NJMCDecoder::dis_c_c(ADDRESS hostpc)
00122 {
00123   static char *logw =  {"",",=",",<",",OD"
00124                             ,",TR",",!=",",>=",",EV"};
00125 /*   static char *logdw[] =  {"",",*=",",*< ",",*OD"
00126                             ,",*TR",",*!=",",*>=",",*EV"}; */
00127   static char *cmpsubw = {"",",=",",<",",<=",",<<",",<<=",
00128                                ",SV",",OD",
00129                                ",TR",",<>",",>=",",>",",>>=",
00130                                ",>>",",NSV",",EV"};
00131   static char *cmpsubdw = {"",",*=",",*<",",*<=",",*<<",",*<<=",
00132                                 ",*SV",",*OD",
00133                                 ",*TR",",*<>",",*>=",",*>",",*>>=",
00134                                 ",*>>",",*NSV",",*EV"};
00135 /*  static char *bitw[]  = {",<", ",>="};*/
00136 /*  static char *bitdw[] = {",*<", ",*>="};*/
00137   
00138     match hostpc to
00139         | c_arith_w(c3_16, neg) => {
00140             apre += sprintf(apre, "%s", cmpsubw[c3_16 + dis_c_c_n(neg)]);
00141             CONS("c_arith_w ")
00142         }
00143         | c_arith_dw(c3_16, neg) => {
00144             apre += sprintf(apre, "%s", cmpsubdw[c3_16 + dis_c_c_n(neg)]);
00145             CONS("c_arith_dw ")
00146         }
00147         | c_cmpb_w(c3_16, neg) => {
00148             apre += sprintf(apre, "%s", cmpsubw[c3_16 + dis_c_c_n(neg)]);
00149             CONS("c_cmpb_w ")
00150         }
00151         | c_cmpb_dw(c3_16, neg) => {
00152             apre += sprintf(apre, "%s", cmpsubdw[c3_16 + dis_c_c_n(neg)]);
00153             CONS("c_cmpb_dw ")
00154         }
00155         | c_sep(c3_16) => {
00156             apre += sprintf(apre, "%s", logw[c3_16]);
00157             CONS("c_sep ")
00158         }
00159         | c_bbs_w(c_16) => {
00160             apre += sprintf(apre, "[%d]",1-c_16);
00161             CONS("c_bbs_w ")
00162         }
00163         | c_bbs_dw(c_16) => {
00164             apre += sprintf(apre, "[%d]",1-c_16);
00165             CONS("c_bbs_dw ")
00166         }
00167         | c_arith_none() => {
00168         }
00169         else {
00170             astr += sprintf(astr, "#c_C%08X", getDword(hostpc));
00171         }
00172   endmatch
00173 }
00174 
00175 void NJMCDecoder::dis_c_xd(ADDRESS hostpc)
00176 {
00177 
00178     match hostpc to
00179         | x_addr_nots(x) =>   {
00180             astr += sprintf(astr, "%s", x_11_names[x]);
00181             CONS("x_addr_nots ")
00182         }
00183         | x_addr_s_byte(x) => {
00184             apre += sprintf(apre, "%s", ",s");
00185             astr += sprintf(astr, "%s", x_11_names[x]);
00186             CONS("x_addr_s_byte ")
00187         }
00188         | x_addr_s_hwrd(x) => {
00189             apre += sprintf(apre, "%s", ",s");
00190             astr += sprintf(astr, "%s", x_11_names[x]);
00191             CONS("x_addr_s_hwrd ")
00192         }
00193         | x_addr_s_word(x) => {
00194             apre += sprintf(apre, "%s", ",s");
00195             astr += sprintf(astr, "%s", x_11_names[x]);
00196             CONS("x_addr_s_word ")
00197         }
00198         | x_addr_s_dwrd(x) => {
00199             apre += sprintf(apre, "%s", ",s");
00200             astr += sprintf(astr, "%s", x_11_names[x]);
00201             CONS("x_addr_s_dwrd ")
00202         }
00203         | s_addr_im_r(i) => {
00204             astr += sprintf(astr, "%d", i);
00205             CONS("s_addr_im_r ")
00206         }
00207         | s_addr_r_im(i) => {
00208             astr += sprintf(astr, "%d", i);
00209             CONS("s_addr_r_im ")
00210         }
00211         | l_addr_16_old(i) => {
00212             astr += sprintf(astr, "%d", i);
00213             CONS("l_addr_16_old ")
00214         }
00215         | l_addr_17_old(i) => {
00216             astr += sprintf(astr, "%d", i);
00217             CONS("l_addr_17_old ")
00218         }
00219         else {
00220             apre += sprintf(apre, "#c_X_ADDR_SHIFT%08X", getDword(hostpc));
00221             astr += sprintf(astr, "#c_X_ADDR_SHIFT%08X", getDword(hostpc));
00222         }
00223     endmatch
00224 }
00225 
00226 void NJMCDecoder::dis_c_wcr(ADDRESS hostpc)
00227 {
00228     unsigned long regl;
00229     match hostpc to
00230     | c_mfctl(r_06) => {
00231         regl = r_06;
00232         CONS("c_mfctl ")
00233     }
00234     | c_mfctl_w() => {
00235         regl = 11;
00236         apre += sprintf(apre, ",w");
00237         CONS("c_mfctl_w ")
00238     }
00239     else {
00240         regl = 0;
00241         apre += sprintf(apre, "#c_WCR%08X#", getDword(hostpc));
00242     }
00243   endmatch
00244   astr += sprintf(astr, "%s", cr_06_names[regl]);
00245 }
00246 
00247 void NJMCDecoder::dis_c_null(ADDRESS hostpc)
00248 {
00249     match hostpc to
00250         | c_br_nnull() => {
00251             CONS("c_br_nnull ")
00252         }
00253         | c_br_null() => {
00254             apre += sprintf(apre, ",n");
00255             CONS("c_br_null ")
00256         }
00257         else
00258             apre += sprintf(apre, "#c_NULL%08X#", getDword(hostpc));
00259   endmatch
00260 }
00261 
00262 void NJMCDecoder::dis_c_bit(ADDRESS hostpc)
00263 {
00264     match hostpc to
00265         | c_bitpos_w(p_06) => {
00266             astr += sprintf(astr, "@%d",p_06);
00267             CONS("c_bitpos_w ")
00268         }
00269         | c_bitsar() => {
00270             astr += sprintf(astr, "%s", "%cr11");
00271             CONS("c_bitsar ")
00272         }
00273         else
00274             astr += sprintf(astr, "#c_BIT%08X#", getDword(hostpc));
00275   endmatch
00276 }
00277 
00278 void NJMCDecoder::dis_c_addr(ADDRESS hostpc)
00279 {
00280     match hostpc to
00281         | c_s_addr_mb() => {
00282             apre += sprintf(apre, ",mb");
00283             CONS("c_s_addr_mb ")
00284         }
00285         | c_s_addr_ma() => {
00286             apre += sprintf(apre, ",ma");
00287             CONS("c_s_addr_ma ")
00288         }
00289         | c_s_addr_notm() => {
00290             CONS("c_s_addr_notm ")
00291         }
00292         | c_x_addr_m() => {
00293             apre += sprintf(apre, ",x");
00294             CONS("c_x_addr_m ")
00295         }
00296         | c_x_addr_notm() => {
00297             CONS("c_x_addr_notm ")
00298         }
00299         | c_y_addr_e() => {
00300             apre += sprintf(apre, ",e");
00301             CONS("c_y_addr_e ")
00302         }
00303         | c_y_addr_me() => {
00304             apre += sprintf(apre, ",me");
00305             CONS("c_y_addr_me ")
00306         }
00307         | c_y_addr_m() => {
00308             apre += sprintf(apre, ",m");
00309             CONS("c_y_addr_m ")
00310         }
00311         | c_y_addr_none() => {
00312             CONS("c_y_addr_none ")
00313         }
00314         | c_l_addr_none() => {
00315             CONS("c_l_addr_none ");
00316         }
00317 
00318 //        | c_addr_s() => {
00319 //            apre += sprintf(apre, ",s");
00320 //            strcat(constrName, "c_addr_s ");
00321 //        }
00322 //        | c_addr_m() => {
00323 //            apre += sprintf(apre, ",m");
00324 //            strcat(constrName, "c_addr_m ");
00325 //        }
00326 //        | c_addr_sm() => {
00327 //            apre += sprintf(apre, ",sm");
00328 //            strcat(constrName, "c_addr_sm ");
00329 //        }
00330 
00331         else
00332             // Do nothing; no completer
00333             CONS("BUG!!");
00334   endmatch
00335 }
00336 
00337 void NJMCDecoder::dis_flt_fmt(int fmt)
00338 {
00339     // Completer for floating point operand size
00340     switch(fmt) {
00341         case 0: apre += sprintf(apre, ",sgl"); break;
00342         case 1: apre += sprintf(apre, ",dbl"); break;
00343         case 3: apre += sprintf(apre, ",quad"); break;
00344         default:apre += sprintf(apre, ",?"); break;
00345     }
00346 }
00347 
00348 static char regbuf;
00349 char* NJMCDecoder::dis_freg(int regNum)
00350 {
00351     if (regNum >= 32)
00352         sprintf(regbuf, "fr%dR", regNum - 32);
00353     else
00354         sprintf(regbuf, "fr%d", regNum);
00355     return regbuf;
00356 }
00357 
00358 //void NJMCDecoder::dis_faddr(ADDRESS faddr)
00359 //{
00360 //    match faddr to
00361 //        | index_faddr (x, s, b) => {
00362 //            astr += sprintf(astr, " %s(%s,%s)", b_06_names[x], s2_16_names[s],
00363 //                b_06_names[b]);
00364 //            strcat(constrName, "index_faddr ");
00365 //        }
00366 //        | sdisps_faddr(d, s, b) => {
00367 //            astr += sprintf(astr, " %d(%s,%s)", d, s2_16_names[s],
00368 //                b_06_names[b]);
00369 //            strcat(constrName, "sdisps_faddr ");
00370 //        }
00371 //    endmatch
00372 //}
00373 
00374 int NJMCDecoder::decodeAssemblyInstruction (ADDRESS pc, int delta)
00375 {
00376     ADDRESS hostPC = pc + delta;
00377     *(apre = aprefix) = '\0';
00378     *(astr = adata) = '\0';
00379     apre += sprintf(apre, "%x: %08x  ", pc, *(unsigned*)hostPC);
00380 
00381     match hostPC to
00382         | NOP => {
00383             apre += sprintf(apre, "%s", "NOP");
00384             CONS("NOP ")
00385         }
00386         | COPY(r, t) => {
00387             apre += sprintf(apre, "%s", "COPY");
00388             astr += sprintf(astr, "%s,%s", r_06_names[r], t_27_names[t]);
00389             CONS("COPY ")
00390          }
00391         | arith(cmplt,r_11,r_06,t_27) => {
00392             ANAME
00393             dis_c_c(cmplt);
00394             astr += sprintf(astr, "%s,%s,%s", r_11_names[r_11],r_06_names[r_06],t_27_names[t_27]);
00395             CONS("arith ")
00396         }
00397         | arith_imm(cmplt, im11_21, r_06, t_11) => {
00398             ANAME
00399             dis_c_c(cmplt);
00400             astr += sprintf(astr, "%d,%s,%s", im11_21, r_06_names[r_06], t_11_names[t_11]);
00401             CONS("arith_imm ")
00402         }
00403         | ADDIL(imm21, r_06) => {
00404             ANAME
00405             astr += sprintf(astr, "%d,%s,%s", imm21, r_06_names[r_06], t_11_names[1]);
00406             CONS("ADDIL ")
00407         }
00408         | LDIL(imm21, t_06) => {
00409             ANAME
00410             astr += sprintf(astr, "0x%x,%s", imm21, t_06_names[t_06]);
00411             CONS("LDIL ")
00412         }
00413         | iloads(c_addr, xd, s, b,t_27) => {
00414             ANAME
00415             dis_c_addr(c_addr);         // Can have ,ma/,mb
00416             dis_c_xd(xd);
00417             astr += sprintf(astr, "(%s,%s),%s",
00418                 s2_16_names[s], b_06_names[b],
00419                 t_27_names[t_27]);
00420             CONS("iloads ")
00421         }
00422         | istores(c_addr, r_11, xd, s, b) => {
00423             ANAME
00424             dis_c_addr(c_addr);         // Can have ,ma/,mb
00425             astr += sprintf(astr, "%s,", r_11_names[r_11]);
00426             dis_c_xd(xd);
00427             astr += sprintf(astr, "(%s,%s)", s2_16_names[s], b_06_names[b]);
00428             CONS("istores ")
00429         }
00430         | iloads_ldisp(c_addr,xd, s, b,t_11) => {
00431             ANAME
00432             IGNORE(c_addr)
00433             dis_c_xd(xd);
00434             astr += sprintf(astr, "(%s,%s),%s", 
00435                 s2_16_names[s], b_06_names[b],
00436                 t_11_names[t_11]);
00437             CONS("iloads_ldisp ")
00438         }
00439         | istores_ldisp(c_addr,r_11,xd, s, b)[name] => {
00440             ANAME
00441             astr += sprintf(astr, "%s,", r_11_names[r_11]);
00442             IGNORE(c_addr)
00443             dis_c_xd(xd);
00444             astr += sprintf(astr, "(%s,%s)",
00445                 s2_16_names[s], b_06_names[b]);
00446             CONS("istores_ldisp ")
00447         }
00448         | LDO(ldisp, b, t)[name] => {
00449             ANAME
00450             astr += sprintf(astr, "%d(%s),%s", ldisp, b_06_names[b], t_06_names[t]);
00451             CONS("LDO ")
00452         }
00453         | VSHD(r1, r2, t, c) => {
00454             ANAME
00455             dis_c_c(c);
00456             astr += sprintf(astr, "%s,%s,%s", r_11_names[r1], r_06_names[r2],
00457                 t_27_names[t]);
00458             CONS("VSHD ")
00459         }
00460         | SHD(r1, r2, p, t, c) => {
00461             ANAME
00462             dis_c_c(c);
00463             astr += sprintf(astr, "%s,%s,%d,%s", r_11_names[r1], r_06_names[r2],
00464                 p, t_27_names[t]);
00465             CONS("SHD ")
00466         }
00467         | ext_var(r, len, t, c) => {
00468             ANAME
00469             dis_c_c(c);
00470             astr += sprintf(astr, "%s,%d,%s", r_11_names[r], len,
00471                 t_27_names[t]);
00472             CONS("ext_var ")
00473         }
00474         | ext_fix(r, p, len, t, c) => {
00475             ANAME
00476             dis_c_c(c);
00477             astr += sprintf(astr, "%s,%d,%d,%s", r_11_names[r], p, len,
00478                 t_27_names[t]);
00479             CONS("ext_fix ")
00480         }
00481         | dep_var(r, len, t, c) => {
00482             ANAME
00483             dis_c_c(c);
00484             astr += sprintf(astr, "%s,%d,%s", r_11_names[r], len,
00485                 t_27_names[t]);
00486             CONS("dep_var ")
00487         }
00488         | dep_fix(r, p, len, t, c) => {
00489             ANAME
00490             dis_c_c(c);
00491             astr += sprintf(astr, "%s,%d,%d,%s", r_11_names[r], p, len,
00492                 t_27_names[t]);
00493             CONS("dep_fix ")
00494         }
00495         | dep_ivar(i, len, t, c) => {
00496             ANAME
00497             dis_c_c(c);
00498             astr += sprintf(astr, "%d,%d,%s", i, len,
00499                 t_27_names[t]);
00500             CONS("dep_ivar ")
00501         }
00502         | dep_ifix(i, p, len, t, c) => {
00503             ANAME
00504             dis_c_c(c);
00505             astr += sprintf(astr, "%d,%d,%d,%s", i, p, len,
00506                 t_27_names[t]);
00507             CONS("dep_ifix ")
00508         }
00509         | ubranch(nulli,ubr_target,t_06) => {
00510             ANAME
00511             dis_c_null(nulli);
00512             // Get the actual destination and its symbol (if possible)
00513             ADDRESS dest = ubr_target + hostPC - delta;
00514             const char* dsym = pBF->SymbolByAddress(dest);
00515             char hexsym;
00516             if (dsym == 0) sprintf(hexsym, "0x%x", dest);
00517             astr += sprintf(astr, "%s, %s", (dsym ? dsym : hexsym), t_06_names[t_06]);
00518             CONS("ubranch ")
00519         }
00520         | BL.LONG(nulli,ubr_target) => {
00521             ANAME
00522             dis_c_null(nulli);
00523             astr += sprintf(astr, "%d %s", ubr_target, t_06_names[2]);
00524             CONS("BL.LONG ")
00525         }
00526         | BLR(nulli,x_11,t_06) => {
00527             ANAME
00528             dis_c_null(nulli);
00529             astr += sprintf(astr, "%s,%s", x_11_names[x_11], t_06_names[t_06]);
00530             CONS("BLR ")
00531         }
00532         | BV(nulli,x_11,b_06) => {
00533             ANAME
00534             dis_c_null(nulli);
00535             astr += sprintf(astr, "%s(%s)", x_11_names[x_11], b_06_names[b_06]);
00536             CONS("BV ")
00537         }
00538         | bve(p_31,nulli,b_06) => {
00539             ANAME
00540             not_used(p_31);
00541             IGNORE(nulli)
00542             astr += sprintf(astr, " (%s)", b_06_names[b_06]);
00543             CONS("bve ")
00544         /* } */
00545         /* PA-RISC 2.0 */
00546         /* | be_all(nulli,cmplt)[name] => { */
00547         /*    ANAME
00548             dis_c_null(nulli);
00549             dis_addr(cmplt);
00550             CONS("be_all ") */
00551         }
00552         | BREAK(im5_27,im13_06)[name] => {
00553             ANAME
00554             astr += sprintf(astr, "%d,%d", im5_27,im13_06);
00555             CONS("BREAK ")
00556         }
00557         | sysop_i_t(im10_06,t_27) => {
00558             ANAME
00559             astr += sprintf(astr, "%d,%s", im10_06,t_27_names[t_27]);
00560             CONS("sysop_i_t ");
00561         }
00562         | sysop_simple => {
00563             ANAME
00564             CONS("sysop_simple ");
00565         }
00566         | sysop_r(r_11) => {
00567             ANAME
00568             astr += sprintf(astr, "%s", r_11_names[r_11]);
00569             CONS("sysop_r ")
00570         }
00571         | sysop_cr_t(cmplt, t_27) => {
00572             ANAME
00573             dis_c_wcr(cmplt);
00574             astr += sprintf(astr, ",%s", t_27_names[t_27]);
00575             CONS("sysop_cr_t ")
00576         }
00577         | MTCTL(r_11, cr_06) => {
00578             ANAME
00579             astr += sprintf(astr, "%s,%s", r_11_names[r_11],cr_06_names[cr_06]);
00580             CONS("MTCTL ")
00581         }
00582         | MFIA(t_27) => {
00583             ANAME
00584             astr += sprintf(astr, "%s", t_27_names[t_27]);
00585             CONS("MFIA ")
00586         }
00587         | LDSID(s2_16,b_06,t_27) => {
00588             ANAME
00589             astr += sprintf(astr, "(%s,%s),%s", s2_16_names[s2_16],
00590               b_06_names[b_06], t_27_names[t_27]);
00591             CONS("LDSID ")
00592         }
00593         | MTSP(r_11,sr) => {
00594             ANAME
00595             astr += sprintf(astr, "%s,%s", r_11_names[r_11],
00596               s3_16_names[sr]);
00597             CONS("MTSP ")
00598         }
00599         | MFSP(sr,t_27) => {
00600             ANAME
00601             astr += sprintf(astr, "%s,%s", s3_16_names[sr],
00602               t_27_names[t_27]);
00603             CONS("MFSP ")
00604         }
00605         | addb_all(c_cmplt, null_cmplt, r_11, r_06, target) => {
00606             ANAME
00607             dis_c_c(c_cmplt);
00608             dis_c_null(null_cmplt);
00609             astr += sprintf(astr, "%s,%s,0x%x", r_11_names[r_11],
00610               r_06_names[r_06], target + pc + 8);
00611             CONS("addb_all ")
00612         }
00613         | addib_all(c_cmplt, null_cmplt, im5, r_06, target) => {
00614             ANAME
00615             dis_c_c(c_cmplt);
00616             dis_c_null(null_cmplt);
00617             astr += sprintf(astr, "%d,%s,0x%x", im5,
00618               r_06_names[r_06], target + pc + 8);
00619             CONS("addb_all ")
00620         }
00621         | cmpb_all(c_cmplt, null_cmplt, r_11, r_06, target) => {
00622             ANAME
00623             dis_c_c(c_cmplt);
00624             dis_c_null(null_cmplt);
00625             astr += sprintf(astr, "%s,%s,0x%x", r_11_names[r_11],
00626               r_06_names[r_06], target + pc + 8);
00627             CONS("cmpb_all ")
00628         }
00629         | cmpib_all(c_cmplt, null_cmplt, im5_11, r_06, target) => {
00630             ANAME
00631             dis_c_c(c_cmplt);
00632             dis_c_null(null_cmplt);
00633             astr += sprintf(astr, "%d,%s,0x%x", im5_11, r_06_names[r_06],
00634               target + pc + 8);
00635             CONS("cmpib_all ")
00636         }
00637         | bb_all(c_cmplt, null_cmplt, r_11, bit_cmplt, target) => {
00638             apre += sprintf(apre, "%s", "BB");
00639             dis_c_c(c_cmplt);
00640             dis_c_null(null_cmplt);
00641             astr += sprintf(astr, "%s,", r_11_names[r_11]);
00642             dis_c_bit(bit_cmplt);
00643             sprintf(astr, ",%x", target + pc + 8);
00644             CONS("bb_all ")
00645         }
00646         | flt_c0_all(fmt, r, t) => {
00647             apre += sprintf(apre, "%s", killDot(name));
00648             dis_flt_fmt(fmt);
00649             astr += sprintf(astr, "%s, ", dis_freg(r));
00650             astr += sprintf(astr, "%s",   dis_freg(t));
00651             CONS("flt_c0_all ")
00652         }
00653         | flt_c1_all(sf, df, r, t) => {
00654             apre += sprintf(apre, "%s", killDot(name));
00655             dis_flt_fmt(sf);
00656             dis_flt_fmt(df);
00657             astr += sprintf(astr, "%s, ", dis_freg(r));
00658             astr += sprintf(astr, "%s",   dis_freg(t));
00659             CONS("flt_c1_all ")
00660         }
00661         | flt_c2_all(fmt, c, r1, r2) => {
00662             apre += sprintf(apre, "%s", killDot(name));
00663             dis_flt_fmt(fmt);
00664             astr += sprintf(astr, "%s, ", dis_freg(r1));
00665             astr += sprintf(astr, "%s",   dis_freg(r2));
00666 // HACK: Needs completer c decoded
00667 astr += sprintf(astr, "\t/* Completer c needs decoding */");
00668 IGNORE(c)
00669             CONS("flt_c2_all ")
00670         }
00671         | flt_c3_all(fmt, r1, r2, t)[name] => {
00672             apre += sprintf(apre, "%s", killDot(name));
00673             dis_flt_fmt(fmt);
00674             astr += sprintf(astr, "%s, ", dis_freg(r1));
00675             astr += sprintf(astr, "%s, ", dis_freg(r2));
00676             astr += sprintf(astr, "%s",   dis_freg(t));
00677             CONS("flt_c3_all ")
00678         }
00679         | XMPYU(r1, r2, t) => {
00680             apre += sprintf(apre, "XMPYU");
00681             astr += sprintf(astr, "%s, ", dis_freg(r1));
00682             astr += sprintf(astr, "%s, ", dis_freg(r2));
00683             astr += sprintf(astr, "%s",   dis_freg(t));
00684             CONS("FMPYU ");
00685         }
00686 
00687 // Floating point loads and stores
00688         | fwloads(c_addr, xd, s, b, t_27) => {
00689             apre += sprintf(apre, "%s",killDot(name));
00690 //          dis_c_addr(c_faddr);
00691             dis_c_addr(c_addr);
00692             dis_c_xd(xd);
00693             astr += sprintf(astr, "(%s,%s),%s",
00694                 s2_16_names[s], b_06_names[b],
00695                 dis_freg(t_27));
00696             CONS("fwloads ")
00697         }
00698         | fwstores(c_addr, r, xd, s, b) => {
00699             apre += sprintf(apre, "%s",killDot(name));
00700 //          dis_c_addr(c_faddr);
00701             dis_c_addr(c_addr);
00702             astr += sprintf(astr, "%s,", dis_freg(r));
00703             dis_c_xd(xd);
00704             astr += sprintf(astr, "(%s,%s)",
00705                 s2_16_names[s], b_06_names[b]);
00706             CONS("fwstores ")
00707         }
00708         | fdloads(c_addr, xd, s, b, t_27) => {
00709             apre += sprintf(apre, "%s",killDot(name));
00710 //          dis_c_addr(c_faddr);
00711             dis_c_addr(c_addr);
00712             dis_c_xd(xd);
00713             astr += sprintf(astr, "(%s,%s),%s",
00714                 s2_16_names[s], b_06_names[b],
00715                 dis_freg(t_27));
00716             CONS("fdloads ")
00717         }
00718         | fdstores(c_addr, r, xd, s, b) => {
00719             apre += sprintf(apre, "%s", killDot(name));
00720 //          dis_c_addr(c_faddr);
00721             dis_c_addr(c_addr);
00722             astr += sprintf(astr, "%s,",   dis_freg(r));
00723             dis_c_xd(xd);
00724             astr += sprintf(astr, "(%s,%s)",
00725                 s2_16_names[s], b_06_names[b]);
00726             CONS("fdstores ")
00727         }
00728 
00729         else
00730             apre += sprintf(apre, "unrecog. %02X %08X",
00731               (getDword(hostPC) >> 26) & 0x3F, getDword(hostPC) & 0x03FFFFFF);
00732     endmatch
00733     // Output the two pieces, and make an attempt to have the second column
00734     // line up (but not have too big a gap between them). 28 seems OK
00735     sprintf(_assembly, "%s%*s%s", aprefix, 28-strlen(aprefix), " ", adata);
00736     return 4;               // Always advance 4 bytes, even for unrecog etc
00737 
00738 }
00739 
00740 /*
00741                 }
00742                 | LDWl(cmplt, ldisp, s2_16, b_06, t_11)[name] => {
00743                         astr += sprintf(astr, "%s", name);
00744                         c_disps(cmplt);
00745                         astr += sprintf(astr, "  %d(%s,%s),%s", ldisp, s2_16_names[s2_16], b_06_names[b_06], t_11_names[t_11]);
00746                 
00747 */

Generated on Tue Sep 19 21:18:22 2006 for Boomerang by  doxygen 1.4.6