srisc1

Download: srisc1.zip

This version tests the ability to read binary memory files (instructions).

The program is designed as a Win32 Console application using UNICODE character I/O.

See: binread

srisc1.cpp


// srisc1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include "binread.h"

void pause();

int _tmain(int argc, _TCHAR* argv[])
{
	wchar_t *filename;
	wchar_t buf[128];
	if (argc>1) filename = argv[1];
	else {
		printf("Enter file name: ");
		_getws_s(buf,127);
		filename = buf;
	}
	binread bin(filename);
	int offset = 0x30;
	if (argc>2) swscanf_s(argv[2],_T("%x"),&offset);
	int address = 0;
	unsigned int contents;
	while (bin.hasNext()) {
		if (address<offset) {
			address += 4;
			continue;
		}
		contents = bin.getInt();
		wprintf(_T("%04x %08x\n"),address,contents);
		address += 4;
		if ((address-offset)>64) break; // debug: shorten output file
	}
	pause();
	return 0;
}

void pause()
{
	fwprintf(stderr,_T("Press any key to exit ...\n"));
	_getch();
}


Results

Compare this output to the original assembled code.

0030 00800284
0034 00c00384
0038 1889c83a
003c 018002c4
0040 01c00184
0044 1911883a
0048 3a13883a
004c 4251c83a
0050 424000c4
0054 10c8703a
0058 10cab03a
005c 10cc303a
0060 10cef03a
0064 12000fcc
0068 003fff06
006c f800283a
0070 01000034


Maintained by John Loomis, updated Thu Feb 15 23:49:59 2007