disasmt.cxx 947 Bytes
#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, &regmask, &symval, &lsreg );
		rspDis_regs( buffer, regmask, dummy );
		cout << ", Ret val " << dec << rv << ": " << buffer << endl;
		addr += 4;
	}
}