disasmt.cxx
947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <fstream.h>
#include <stdlib.h>
extern "C" {
void rspDis_init( char *, char *, char *[], int );
void rspDis_regs( char *buffer, unsigned regmask, unsigned reg_values[] );
int rspDisasm( char *, unsigned, unsigned, unsigned *, unsigned *, unsigned *);
};
char buffer[64];
unsigned int regmask, symval, lsreg, addr;
unsigned int dummy[32];
void main( int argc, char ** argv )
{
unsigned long value;
int rv;
ifstream in;
if ( argc != 2 )
{
cerr << "Usage: disasm <file>" << endl;
exit( 1 );
}
in.open( argv[1], 0 );
if ( in.fail() )
{
cerr << "Couldn't open " << argv[1] << endl;
exit( 1 );
}
for ( ;; )
{
in.read( (char *) &value, 4 );
if ( in.eof() )
exit( 0 );
cout << "Disassembling " << hex << value;
rv = rspDisasm( buffer, addr, (unsigned) value, ®mask, &symval, &lsreg );
rspDis_regs( buffer, regmask, dummy );
cout << ", Ret val " << dec << rv << ": " << buffer << endl;
addr += 4;
}
}