Mercurial > repos > blastem
comparison gentests.py @ 227:42123feab62d
Added test cases for divs/divu and added divide by zero handler to test generator
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 21 Apr 2013 16:44:10 -0700 |
parents | f7ff02eeec2f |
children | 8db584faac4b |
comparison
equal
deleted
inserted
replaced
226:28a6697e847b | 227:42123feab62d |
---|---|
21 def name(self): | 21 def name(self): |
22 return str(self.inst).replace('.', '_').replace('#', '_').replace(',', '_').replace(' ', '_').replace('(', '[').replace(')', ']') | 22 return str(self.inst).replace('.', '_').replace('#', '_').replace(',', '_').replace(' ', '_').replace('(', '[').replace(')', ']') |
23 | 23 |
24 def write_rom_test(self, outfile): | 24 def write_rom_test(self, outfile): |
25 outfile.write('\tdc.l $0, start\n') | 25 outfile.write('\tdc.l $0, start\n') |
26 needdivzero = self.inst.name.startswith('div') | |
26 for i in xrange(0x8, 0x100, 0x4): | 27 for i in xrange(0x8, 0x100, 0x4): |
27 outfile.write('\tdc.l empty_handler\n') | 28 if needdivzero and i == 0x14: |
28 outfile.write('\tdc.b "SEGA"\nempty_handler:\n\trte\nstart:\n') | 29 outfile.write('\tdc.l div_zero_handler\n') |
29 outfile.write('\tmove #0, CCR\n') | 30 else: |
31 outfile.write('\tdc.l empty_handler\n') | |
32 outfile.write('\tdc.b "SEGA"\nempty_handler:\n\trte\n') | |
33 if needdivzero: | |
34 outfile.write('div_zero_handler:\n') | |
35 div_zero_count = self.get_dreg() | |
36 outfile.write('\taddq #1, ' + str(div_zero_count) + '\n') | |
37 outfile.write('\trte\n') | |
38 outfile.write('start:\n\tmove #0, CCR\n') | |
39 if needdivzero: | |
40 outfile.write('\tmoveq #0, ' + str(div_zero_count) + '\n') | |
30 already = {} | 41 already = {} |
31 self.inst.write_init(outfile, already) | 42 self.inst.write_init(outfile, already) |
32 if 'label' in already: | 43 if 'label' in already: |
33 outfile.write('lbl_' + str(already['label']) + ':\n') | 44 outfile.write('lbl_' + str(already['label']) + ':\n') |
34 outfile.write('\t'+str(self.inst)+'\n') | 45 outfile.write('\t'+str(self.inst)+'\n') |