disassembler9.m

Go to the documentation of this file.
00001 
00002 /*
00003   void NJMCDecoder :: Cmplt_1(ADDRESS hostpc1)
00004   {
00005   }
00006 
00007   void NJMCDecoder :: Cmplt_2(ADDRESS hostpc2)
00008   {
00009   }
00010 
00011   void NJMCDecoder :: Cmplt_3(ADDRESS hostpc3)
00012   {
00013   }
00014  */
00015 
00016 
00017 #include "global.h"
00018 #include "decoder.h"
00019 #include "BinaryFile.h"
00020 
00021 #include "hppa-names.h"
00022 
00023 // globals
00024 extern char _assembly;
00025 char* astr;
00026 char *cmpltsep = ".";       // ??
00027 
00028 // Prototypes
00029 const char* GetSym(unsigned pc);
00030 const char* GetReloc(unsigned pc);
00031 
00032 
00033 DWord getDword (unsigned lc)
00034 /* get4Bytes - returns next 4-Byte from image pointed to by lc.
00035    Fetch in a big-endian manner  */
00036 {
00037     return
00038       (DWord)
00039       ((((((
00040           *(Byte *)lc << 8
00041       ) + *(Byte *)(lc+1)) << 8
00042       ) + *(Byte *)(lc+2)) << 8
00043       ) + *(Byte *)(lc+3));
00044 }
00045 
00046 
00047 void NJMCDecoder::dis_flt_fmt(int fmt)
00048 {
00049     // Completer for floating point operand size
00050     switch(fmt) {
00051         case 0: astr += sprintf(astr, ",sgl"); break;
00052         case 1: astr += sprintf(astr, ",dbl"); break;
00053         case 3: astr += sprintf(astr, ",quad"); break;
00054         default:astr += sprintf(astr, ",?"); break;
00055     }
00056 }
00057 
00058 int NJMCDecoder::decodeAssemblyInstruction (ADDRESS pc, int delta)
00059 {
00060     char sCmplt;
00061     unsigned long r1,r2;
00062     sCmplt='\0';
00063     ADDRESS hostPC = pc + delta;
00064 
00065     astr = _assembly + sprintf(_assembly, "%x: %08x  ", pc, *(unsigned*)hostPC);
00066 
00067     match hostPC to
00068         | flt_c0(fmt, r, t) => {
00069             astr += sprintf(astr, "%s", name);
00070             dis_flt_fmt(fmt);
00071             astr += sprintf(astr, "  fr%d, fr%d", r, t);
00072             strcat(constrName, "flt_c0 ");
00073         }
00074         | flt_c1(sf, df, r, t) => {
00075             astr += sprintf(astr, "%s", name);
00076             dis_flt_fmt(sf);
00077             dis_flt_fmt(df);
00078             astr += sprintf(astr, "  fr%d, fr%d", r, t);
00079             strcat(constrName, "flt_c1 ");
00080         }
00081         | flt_c2_0c(r1, r2, c, fmt) => {
00082             astr += sprintf(astr, "%s", name);
00083             dis_flt_fmt(fmt);
00084             astr += sprintf(astr, "  %fr%d, fr%d", r1, r2);
00085 // HACK: Needs completer c decoded
00086 astr += sprintf(astr, "\t\t/* Completer c needs decoding */");
00087             strcat(constrName, "flt_c2_0c ");
00088         }
00089         | flt_c2_0e(r1, r2, c, fmt) => {
00090             astr += sprintf(astr, "%s", name);
00091             dis_flt_fmt(fmt);
00092             astr += sprintf(astr, "  fr%d, fr%d", r1, r2);
00093 // HACK: Needs completer c decoded
00094 astr += sprintf(astr, "\t\t/* Completer c needs decoding */");
00095             strcat(constrName, "flt_c2_0e ");
00096         }
00097         | flt_c3_0c(r1, r2, t, fmt) => {
00098             astr += sprintf(astr, "%s", name);
00099             dis_flt_fmt(fmt);
00100             astr += sprintf(astr, "  fr%d, fr%d, fr%d", r1, r2, t);
00101             strcat(constrName, "flt_c3_0c ");
00102         }
00103         | flt_c3_0e(r1, r2, t, fmt) => {
00104             astr += sprintf(astr, "%s", name);
00105             dis_flt_fmt(fmt);
00106             astr += sprintf(astr, "  fr%d, fr%d, fr%d", r1, r2, t);
00107             strcat(constrName, "flt_c3_0e ");
00108         }
00109 
00110         else
00111             astr += sprintf(astr, "unrecog. %02X %08X",
00112               (getDword(hostPC) >> 26) & 0x3F, getDword(hostPC) & 0x03FFFFFF);
00113     endmatch
00114 
00115     return 4;               // Always advance 4 bytes, even for unrecog etc
00116 
00117 }
00118 
00119 /*
00120                 }
00121                 | LDWl(cmplt, ldisp, s2_16, b_06, t_11)[name] => {
00122                         astr += sprintf(astr, "%s", name);
00123                         c_disps(cmplt);
00124                         astr += sprintf(astr, "  %d(%s,%s),%s", ldisp, s2_16_names[s2_16], b_06_names[b_06], t_11_names[t_11]);
00125                 
00126 */

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