view dis.c @ 9:0a0cd3705c19

Implement (possibly broken) decoding of all M68000 instructions not in the OR_DIV_SBCD group
author Mike Pavone <pavone@retrodev.com>
date Tue, 13 Nov 2012 18:26:43 -0800
parents 23b83d94c633
children 168b1a873895
line wrap: on
line source

#include "68kinst.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char ** argv)
{
	long filesize;
	unsigned short *filebuf;
	char disbuf[1024];
	m68kinst instbuf;
	unsigned short * cur;
	FILE * f = fopen(argv[1], "rb");
	fseek(f, 0, SEEK_END);
	filesize = ftell(f);
	fseek(f, 0, SEEK_SET);
	filebuf = malloc(filesize);
	fread(filebuf, 2, filesize/2, f);
	fclose(f);
	for(cur = filebuf; cur - filebuf < (filesize/2); ++cur)
	{
		*cur = (*cur >> 8) | (*cur << 8);
	}
	for(cur = filebuf; (cur - filebuf) < (filesize/2); )
	{
		//printf("cur: %p: %x\n", cur, *cur);
		cur = m68K_decode(cur, &instbuf);
		m68k_disasm(&instbuf, disbuf);
		puts(disbuf);
	}
	return 0;
}