Mercurial > repos > blastem
view dis.c @ 18:3e7bfde7606e
M68K to x86 translation works for a limited subset of instructions and addressing modes
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 04 Dec 2012 19:13:12 -0800 |
parents | 168b1a873895 |
children | f664eeb55cb4 |
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); unsigned short * start = cur; cur = m68k_decode(cur, &instbuf, (start - filebuf)*2); m68k_disasm(&instbuf, disbuf); printf("%X: %s\n", instbuf.address, disbuf); } return 0; }