# HG changeset patch # User Mike Pavone # Date 1366587850 25200 # Node ID 42123feab62dc99db7ff1292f7cdbb313f22b025 # Parent 28a6697e847bc110ee351a3fe97e85dceb292d8a Added test cases for divs/divu and added divide by zero handler to test generator diff -r 28a6697e847b -r 42123feab62d gentests.py --- a/gentests.py Sun Apr 21 13:00:34 2013 -0700 +++ b/gentests.py Sun Apr 21 16:44:10 2013 -0700 @@ -23,10 +23,21 @@ def write_rom_test(self, outfile): outfile.write('\tdc.l $0, start\n') + needdivzero = self.inst.name.startswith('div') for i in xrange(0x8, 0x100, 0x4): - outfile.write('\tdc.l empty_handler\n') - outfile.write('\tdc.b "SEGA"\nempty_handler:\n\trte\nstart:\n') - outfile.write('\tmove #0, CCR\n') + if needdivzero and i == 0x14: + outfile.write('\tdc.l div_zero_handler\n') + else: + outfile.write('\tdc.l empty_handler\n') + outfile.write('\tdc.b "SEGA"\nempty_handler:\n\trte\n') + if needdivzero: + outfile.write('div_zero_handler:\n') + div_zero_count = self.get_dreg() + outfile.write('\taddq #1, ' + str(div_zero_count) + '\n') + outfile.write('\trte\n') + outfile.write('start:\n\tmove #0, CCR\n') + if needdivzero: + outfile.write('\tmoveq #0, ' + str(div_zero_count) + '\n') already = {} self.inst.write_init(outfile, already) if 'label' in already: diff -r 28a6697e847b -r 42123feab62d testcases.txt --- a/testcases.txt Sun Apr 21 13:00:34 2013 -0700 +++ b/testcases.txt Sun Apr 21 16:44:10 2013 -0700 @@ -38,7 +38,9 @@ #mulu w d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x) d #move bwl d;a;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x) d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l #movea wl d;a;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x) a -moveq l #(-128-127) d -roxl bwl d;#(1-8) d -roxr bwl d;#(1-8) d +#moveq l #(-128-127) d +#roxl bwl d;#(1-8) d +#roxr bwl d;#(1-8) d +divs w d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x) d +divu w d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x) d