summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcomparetests.py52
-rw-r--r--testcases.txt1
-rw-r--r--trans.c6
3 files changed, 50 insertions, 9 deletions
diff --git a/comparetests.py b/comparetests.py
index ce62ae2..3448fd4 100755
--- a/comparetests.py
+++ b/comparetests.py
@@ -18,6 +18,49 @@ for i in range(1, len(argv)):
else:
prefixes.append(argv[i])
+def print_mismatch(path, b, m):
+ blines = b.split('\n')
+ mlines = m.split('\n')
+ if len(blines) != len(mlines):
+ print '-----------------------------'
+ print 'Unknown mismatch in', path
+ print 'blastem output:'
+ print b
+ print 'musashi output:'
+ print m
+ print '-----------------------------'
+ return
+ prevline = ''
+ differences = []
+ flagmismatch = False
+ regmismatch = False
+ for i in xrange(0, len(blines)):
+ if blines[i] != mlines[i]:
+ if prevline == 'XNZVC':
+ differences.append((prevline, prevline))
+ flagmismatch = True
+ else:
+ regmismatch = True
+ differences.append((blines[i], mlines[i]))
+ prevline = blines[i]
+ if flagmismatch and regmismatch:
+ mtype = 'General'
+ elif flagmismatch:
+ mtype = 'Flag'
+ elif regmismatch:
+ mtype = 'Register'
+ else:
+ mtype = 'Unknown'
+ print '-----------------------------'
+ print mtype, 'mismatch in', path
+ for i in xrange(0, 2):
+ print 'musashi' if i else 'blastem', 'output:'
+ for diff in differences:
+ print diff[i]
+ print '-----------------------------'
+
+
+
for path in glob('generated_tests/*/*.bin'):
if path in skip:
continue
@@ -36,13 +79,8 @@ for path in glob('generated_tests/*/*.bin'):
m = subprocess.check_output(['musashi/mustrans', path])
#_,_,b = b.partition('\n')
if b != m:
- print '-----------------------------'
- print 'Mismatch in ' + path
- print 'blastem output:'
- print b
- print 'musashi output:'
- print m
- print '-----------------------------'
+ print_mismatch(path, b, m)
+
else:
print path, 'passed'
except subprocess.CalledProcessError as e:
diff --git a/testcases.txt b/testcases.txt
index b7f7d34..3ece10a 100644
--- a/testcases.txt
+++ b/testcases.txt
@@ -84,4 +84,5 @@ Name Sizes Src Modes Dst Modes
#sle b d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
#swap w d
tst bwl d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+lea l (a);(n,a);(n,a,x);(n).w;(n).l;(n,pc);(n,pc,x) a
diff --git a/trans.c b/trans.c
index d73ebc5..2f98e91 100644
--- a/trans.c
+++ b/trans.c
@@ -30,8 +30,9 @@ int main(int argc, char ** argv)
fseek(f, 0, SEEK_END);
filesize = ftell(f);
fseek(f, 0, SEEK_SET);
- filebuf = malloc(filesize > 0x400000 ? filesize : 0x400000);
- fread(filebuf, 2, filesize/2, f);
+ filebuf = malloc(0x400000);
+ memset(filebuf, 0, 0x400000);
+ fread(filebuf, 2, filesize/2 > 0x200000 ? 0x200000 : filesize/2, f);
fclose(f);
for(cur = filebuf; cur - filebuf < (filesize/2); ++cur)
{
@@ -49,6 +50,7 @@ int main(int argc, char ** argv)
memmap[1].mask = 0xFFFF;
memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE;
memmap[1].buffer = malloc(64 * 1024);
+ memset(memmap[1].buffer, 0, 64 * 1024);
init_m68k_opts(&opts, memmap, 2);
init_68k_context(&context, opts.gen.native_code_map, &opts);
context.mem_pointers[0] = memmap[0].buffer;