Mercurial > repos > blastem
annotate ztestgen.c @ 689:858e31f977ae
A couple more indentation fixes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 08 Jan 2015 23:20:41 -0800 |
parents | 3072fb746601 |
children | a6c6b621d0dc |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
400
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
400
diff
changeset
|
2 Copyright 2013 Michael Pavone |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
400
diff
changeset
|
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
400
diff
changeset
|
5 */ |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include "z80inst.h" |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include <stdlib.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include <string.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include <stdint.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 #include <stdio.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 #include <sys/stat.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #include <sys/types.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 #include <errno.h> |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 extern z80inst z80_tbl_a[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 extern z80inst z80_tbl_extd[0xC0-0x40]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 extern z80inst z80_tbl_bit[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 extern z80inst z80_tbl_ix[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 extern z80inst z80_tbl_iy[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 extern z80inst z80_tbl_ix_bit[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 extern z80inst z80_tbl_iy_bit[256]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 extern char *z80_mnemonics[Z80_OTDR+1]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 extern char * z80_regs[Z80_USE_IMMED]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 #define PRE_IX 0xDD |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 #define PRE_IY 0xFD |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 #define LD_IR16 0x01 |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
27 #define INC_R8 0x04 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 #define LD_IR8 0x06 |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
29 #define LD_RR8 0x40 |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
30 #define AND_R 0xA0 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 #define PUSH 0xC5 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 #define POP 0xC1 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 uint8_t * ld_ir16(uint8_t * dst, uint8_t reg, uint16_t val) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 if (reg == Z80_IX) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 *(dst++) = PRE_IX; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 return ld_ir16(dst, Z80_HL, val); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } else if(reg == Z80_IY) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 *(dst++) = PRE_IY; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 return ld_ir16(dst, Z80_HL, val); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 *(dst++) = LD_IR16 | ((reg - Z80_BC) << 4); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 *(dst++) = val & 0xFF; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 *(dst++) = val >> 8; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 return dst; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 uint8_t * ld_ir8(uint8_t * dst, uint8_t reg, uint8_t val) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 if (reg <= Z80_H) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 reg = (reg - Z80_C) ^ 1; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 reg = 0x7; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 *(dst++) = LD_IR8 | (reg << 3); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 *(dst++) = val; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 return dst; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
62 uint8_t * ld_rr8(uint8_t * dst, uint8_t src, uint8_t dstr) |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
63 { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
64 if (src <= Z80_H) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
65 src = (src - Z80_C) ^ 1; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
66 } else { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
67 src = 0x7; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
68 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
69 if (dstr <= Z80_H) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
70 dstr = (dstr - Z80_C) ^ 1; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
71 } else { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
72 dstr = 0x7; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
73 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
74 *(dst++) = LD_RR8 | (dstr << 3) | src; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
75 return dst; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
76 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
77 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 uint8_t * ld_amem(uint8_t * dst, uint16_t address) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 *(dst++) = 0x32; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 *(dst++) = address & 0xFF; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 *(dst++) = address >> 8; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 return dst; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
86 uint8_t * ld_mema(uint8_t * dst, uint16_t address) |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
87 { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
88 *(dst++) = 0x3A; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
89 *(dst++) = address & 0xFF; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
90 *(dst++) = address >> 8; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
91 return dst; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
92 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
93 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 uint8_t * push(uint8_t * dst, uint8_t reg) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 if (reg == Z80_IX) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 *(dst++) = PRE_IX; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 return push(dst, Z80_HL); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 } else if(reg == Z80_IY) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 *(dst++) = PRE_IY; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 return push(dst, Z80_HL); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 if (reg == Z80_AF) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 reg--; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 *(dst++) = PUSH | ((reg - Z80_BC) << 4); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 return dst; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 uint8_t * pop(uint8_t * dst, uint8_t reg) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 if (reg == Z80_IX) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 *(dst++) = PRE_IX; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 return pop(dst, Z80_HL); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 } else if(reg == Z80_IY) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 *(dst++) = PRE_IY; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 return pop(dst, Z80_HL); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 if (reg == Z80_AF) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 reg--; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 *(dst++) = POP | ((reg - Z80_BC) << 4); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 return dst; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
128 uint8_t * and_r(uint8_t * dst, uint8_t reg) |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
129 { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
130 if (reg == Z80_IXH || reg == Z80_IXL) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
131 *(dst++) = PRE_IX; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
132 return and_r(dst, reg - (Z80_IXL - Z80_L)); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
133 } else if(reg == Z80_IYH || reg == Z80_IYL) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
134 *(dst++) = PRE_IY; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
135 return and_r(dst, reg - (Z80_IYL - Z80_L)); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
136 } else { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
137 if (reg == Z80_A) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
138 reg = 7; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
139 } else { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
140 reg = (reg - Z80_C) ^ 1; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
141 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
142 *(dst++) = AND_R | reg; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
143 return dst; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
144 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
145 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
146 |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
147 uint8_t * inc_r(uint8_t *dst, uint8_t reg) |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
148 { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
149 if (reg == Z80_IXH || reg == Z80_IXL) { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
150 *(dst++) = PRE_IX; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
151 return inc_r(dst, reg - (Z80_IXL - Z80_L)); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
152 } else if(reg == Z80_IYH || reg == Z80_IYL) { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
153 *(dst++) = PRE_IY; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
154 return inc_r(dst, reg - (Z80_IYL - Z80_L)); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
155 } else { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
156 *(dst++) = INC_R8 | reg << 3; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
157 return dst; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
158 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
159 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
160 |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
161 void mark_used8(uint8_t *reg_usage, uint16_t *reg_values, uint8_t reg, uint8_t init_value) |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
162 { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
163 reg_usage[reg] = 1; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
164 reg_values[reg] = init_value; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
165 uint8_t word_reg = z80_word_reg(reg); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
166 if (word_reg != Z80_UNUSED) { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
167 reg_usage[word_reg] = 1; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
168 reg_values[word_reg] = (reg_values[z80_high_reg(word_reg)] << 8) | (reg_values[z80_low_reg(word_reg)] & 0xFF); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
169 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
170 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
171 |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
172 uint8_t alloc_reg8(uint8_t *reg_usage, uint16_t *reg_values, uint8_t init_value) |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
173 { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
174 for (uint8_t reg = 0; reg < Z80_BC; reg++) |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
175 { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
176 if (!reg_usage[reg]) { |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
177 mark_used8(reg_usage, reg_values, reg, init_value); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
178 return reg; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
179 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
180 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
181 return Z80_UNUSED; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
182 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
183 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 void z80_gen_test(z80inst * inst, uint8_t *instbuf, uint8_t instlen) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 z80inst copy; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 uint16_t reg_values[Z80_UNUSED]; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
188 uint8_t reg_usage[Z80_UNUSED]; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 memset(reg_values, 0, sizeof(reg_values)); |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
190 memset(reg_usage, 0, sizeof(reg_usage)); |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 uint8_t addr_mode = inst->addr_mode & 0x1F; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 uint8_t word_sized = ((inst->reg != Z80_USE_IMMED && inst->reg != Z80_UNUSED && inst->reg >= Z80_BC) || (addr_mode == Z80_REG && inst->ea_reg >= Z80_BC)) ? 1 : 0; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 if (inst->reg == Z80_USE_IMMED || addr_mode == Z80_IMMED || addr_mode == Z80_IMMED_INDIRECT |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 || addr_mode == Z80_IX_DISPLACE || addr_mode == Z80_IY_DISPLACE) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 memcpy(©, inst, sizeof(copy)); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 inst = © |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
199 if ((inst->reg == Z80_USE_IMMED && inst->op != Z80_BIT && inst->op != Z80_RES && inst->op != Z80_SET) |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 || (addr_mode == Z80_IMMED && inst->op != Z80_IM)) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 copy.immed = rand() % (word_sized ? 65536 : 256); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 if (addr_mode == Z80_IX_DISPLACE || addr_mode == Z80_IY_DISPLACE) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 copy.ea_reg = rand() % 256; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 if (addr_mode == Z80_IMMED_INDIRECT) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 copy.immed = 0x1000 + (rand() % 256 - 128); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 uint8_t is_mem = 0; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 uint16_t address; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 int16_t offset; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 switch(addr_mode) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 case Z80_REG: |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
217 reg_usage[inst->ea_reg] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 if (word_sized) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 reg_values[inst->ea_reg] = rand() % 65536; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 reg_values[z80_high_reg(inst->ea_reg)] = reg_values[inst->ea_reg] >> 8; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
221 reg_usage[z80_high_reg(inst->ea_reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 reg_values[z80_low_reg(inst->ea_reg)] = reg_values[inst->ea_reg] & 0xFF; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
223 reg_usage[z80_low_reg(inst->ea_reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 } else { |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
225 mark_used8(reg_usage, reg_values, inst->ea_reg, rand() % 256); |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 break; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 case Z80_REG_INDIRECT: |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 is_mem = 1; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 reg_values[inst->ea_reg] = 0x1000 + (rand() % 256 - 128); |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
231 reg_usage[inst->ea_reg] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 address = reg_values[inst->ea_reg]; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
233 reg_usage[z80_high_reg(inst->ea_reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 reg_values[z80_high_reg(inst->ea_reg)] = reg_values[inst->ea_reg] >> 8; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
235 reg_usage[z80_low_reg(inst->ea_reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 reg_values[z80_low_reg(inst->ea_reg)] = reg_values[inst->ea_reg] & 0xFF; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 break; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 case Z80_IMMED_INDIRECT: |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 is_mem = 1; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 address = inst->immed; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 break; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 case Z80_IX_DISPLACE: |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 reg_values[Z80_IX] = 0x1000; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
244 reg_usage[Z80_IX] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 reg_values[Z80_IXH] = 0x10; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
246 reg_usage[Z80_IXH] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 reg_values[Z80_IXL] = 0; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
248 reg_usage[Z80_IXL] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 is_mem = 1; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 offset = inst->ea_reg; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 if (offset > 0x7F) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 offset -= 256; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 address = 0x1000 + offset; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 break; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 case Z80_IY_DISPLACE: |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 reg_values[Z80_IY] = 0x1000; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
258 reg_usage[Z80_IY] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 reg_values[Z80_IYH] = 0x10; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
260 reg_usage[Z80_IYH] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 reg_values[Z80_IYL] = 0; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
262 reg_usage[Z80_IYL] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 is_mem = 1; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 offset = inst->ea_reg; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 if (offset > 0x7F) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 offset -= 256; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 address = 0x1000 + offset; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 break; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 if (inst->reg != Z80_UNUSED && inst->reg != Z80_USE_IMMED) { |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
272 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 if (word_sized) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 reg_values[inst->reg] = rand() % 65536; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
275 reg_usage[z80_high_reg(inst->reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 reg_values[z80_high_reg(inst->reg)] = reg_values[inst->reg] >> 8; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
277 reg_usage[z80_low_reg(inst->reg)] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 reg_values[z80_low_reg(inst->reg)] = reg_values[inst->reg] & 0xFF; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 } else { |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
280 if (!reg_usage[inst->reg]) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
281 reg_values[inst->reg] = rand() % 255; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
282 uint8_t word_reg = z80_word_reg(inst->reg); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
283 if (word_reg != Z80_UNUSED) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
284 reg_usage[word_reg] = 1; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
285 reg_values[word_reg] = (reg_values[z80_high_reg(word_reg)] << 8) | (reg_values[z80_low_reg(word_reg)] & 0xFF); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
286 } |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 } |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
289 reg_usage[inst->reg] = 1; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 } |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
291 uint8_t counter_reg = Z80_UNUSED; |
619
3072fb746601
Added support for JR and JRcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
618
diff
changeset
|
292 if (inst->op >= Z80_JP && inst->op <= Z80_JRCC) { |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
293 counter_reg = alloc_reg8(reg_usage, reg_values, 0); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
294 } |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 puts("--------------"); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 for (uint8_t reg = 0; reg < Z80_UNUSED; reg++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 if (reg_values[reg]) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 printf("%s: %X\n", z80_regs[reg], reg_values[reg]); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 char disbuf[80]; |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
302 z80_disasm(inst, disbuf, 0); |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 puts(disbuf); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 char pathbuf[128]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 sprintf(pathbuf, "ztests/%s", z80_mnemonics[inst->op]); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 if (mkdir(pathbuf, 0777) != 0) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 if (errno != EEXIST) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 fprintf(stderr, "Failed to create directory %s\n", disbuf); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 exit(1); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 uint8_t prog[200]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 uint8_t *cur = prog; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 uint8_t mem_val; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 //disable interrupts |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 *(cur++) = 0xF3; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 //setup SP |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 cur = ld_ir16(cur, Z80_SP, 0x2000); |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
319 for (int i = 0; i < 2; i ++) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
320 //setup memory |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
321 if (is_mem) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
322 mem_val = rand() % 256; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
323 cur = ld_ir8(cur, Z80_A, mem_val); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
324 cur = ld_amem(cur, address); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
325 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
326 //setup AF |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
327 cur = ld_ir16(cur, Z80_BC, reg_values[Z80_A] << 8 | (i ? 0xFF : 0)); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
328 cur = push(cur, Z80_BC); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
329 cur = pop(cur, Z80_AF); |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
330 |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
331 //setup other regs |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
332 for (uint8_t reg = Z80_BC; reg <= Z80_IY; reg++) { |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
333 if (reg != Z80_AF && reg != Z80_SP && (inst->op != Z80_JP || addr_mode != Z80_REG_INDIRECT || inst->ea_reg != reg)) { |
618
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
334 if (i == 1 && (z80_high_reg(reg) == counter_reg || z80_low_reg(reg) == counter_reg)) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
335 if (z80_high_reg(reg) == counter_reg) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
336 if (reg_usage[z80_low_reg(reg)]) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
337 cur = ld_ir8(cur, z80_low_reg(reg), reg_values[z80_low_reg(reg)]); |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
338 } |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
339 } else if (reg_usage[z80_high_reg(reg)]) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
340 cur = ld_ir8(cur, z80_high_reg(reg), reg_values[z80_high_reg(reg)]); |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
341 } |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
342 } else { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
343 cur = ld_ir16(cur, reg, reg_values[reg]); |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
344 } |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
345 } |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 } |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
347 |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
348 if (inst->op == Z80_JP && addr_mode == Z80_REG_INDIRECT) { |
618
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
349 uint16_t address = cur - prog + (inst->ea_reg == Z80_HL ? 3 : 4) + instlen + 1 + i; |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
350 cur = ld_ir16(cur, inst->ea_reg, address); |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
351 } |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
352 |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
353 //copy instruction |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
354 if (instlen == 3) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
355 memcpy(cur, instbuf, 2); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
356 cur += 2; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
357 } else { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
358 memcpy(cur, instbuf, instlen); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
359 cur += instlen; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
360 } |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
361 |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
362 //immed/displacement byte(s) |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
363 if (addr_mode == Z80_IX_DISPLACE || addr_mode == Z80_IY_DISPLACE) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
364 *(cur++) = inst->ea_reg; |
618
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
365 } else if ((inst->op == Z80_JP || inst->op == Z80_JPCC) && addr_mode == Z80_IMMED) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
366 uint16_t address = cur - prog + 3 + i; //2 for immed address, 1/2 for instruction(s) to skip |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
367 *(cur++) = address; |
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
368 *(cur++) = address >> 8; |
619
3072fb746601
Added support for JR and JRcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
618
diff
changeset
|
369 } else if(inst->op == Z80_JR || inst->op == Z80_JRCC) { |
3072fb746601
Added support for JR and JRcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
618
diff
changeset
|
370 *(cur++) = 1 + i; //skip one or 2 instructions based on value of i |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
371 } else if (addr_mode == Z80_IMMED & inst->op != Z80_IM) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
372 *(cur++) = inst->immed & 0xFF; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
373 if (word_sized) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
374 *(cur++) = inst->immed >> 8; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
375 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
376 } else if (addr_mode == Z80_IMMED_INDIRECT) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
377 *(cur++) = inst->immed & 0xFF; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 *(cur++) = inst->immed >> 8; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 } |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
380 if (inst->reg == Z80_USE_IMMED && inst->op != Z80_BIT && inst->op != Z80_RES && inst->op != Z80_SET) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
381 *(cur++) = inst->immed & 0xFF; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
382 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
383 if (instlen == 3) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
384 *(cur++) = instbuf[2]; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
385 } |
619
3072fb746601
Added support for JR and JRcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
618
diff
changeset
|
386 if (inst->op >= Z80_JP && inst->op <= Z80_JRCC) { |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
387 cur = inc_r(cur, counter_reg); |
618
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
388 if (i) { |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
389 //inc twice on second iteration so we can differentiate the two |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
390 cur = inc_r(cur, counter_reg); |
abc834e4a520
Added support for JPcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
617
diff
changeset
|
391 } |
617
33ff0171301b
Added support for JP in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
505
diff
changeset
|
392 } |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
393 if (!i) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
394 //Save AF from first run |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
395 cur = push(cur, Z80_AF); |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
396 if (is_mem) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
397 //Save memory location from frist run |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
398 cur = ld_mema(cur, address); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
399 cur = push(cur, Z80_AF); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
400 } |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
401 } else { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
402 //Pop AF from first run for final result |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
403 for (int reg = Z80_BC; reg <= Z80_IY; reg++) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
404 if (reg != Z80_AF && !reg_usage[reg]) { |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
405 cur = pop(cur, reg); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
406 cur = push(cur, Z80_AF); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
407 cur = ld_ir8(cur, Z80_A, 0xC7); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
408 cur = and_r(cur, z80_low_reg(reg)); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
409 cur = ld_rr8(cur, Z80_A, z80_low_reg(reg)); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
410 cur = pop(cur, Z80_AF); |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
411 reg_usage[reg] = 1; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
412 reg_usage[z80_low_reg(reg)] = 1; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
413 break; |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
414 } |
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
415 } |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
416 if (is_mem) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
417 //Pop memory location from frist run |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
418 for (int reg = Z80_BC; reg <= Z80_IY; reg++) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
419 if (reg != Z80_AF && !reg_usage[reg]) { |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
420 cur = pop(cur, reg); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
421 cur = push(cur, Z80_AF); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
422 cur = ld_mema(cur, address); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
423 cur = ld_rr8(cur, Z80_A, z80_low_reg(reg)); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
424 cur = pop(cur, Z80_AF); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
425 reg_usage[reg] = 1; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
426 reg_usage[z80_low_reg(reg)] = 1; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
427 break; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
428 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
429 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
430 } |
400
a09aa6d067fd
Have test generator test both flag register 0 case and flag register FF case
Mike Pavone <pavone@retrodev.com>
parents:
391
diff
changeset
|
431 } |
298
170722e80fc0
Fix handling of instructions that combine an IX/IY displacement with another prefix in test generator
Mike Pavone <pavone@retrodev.com>
parents:
296
diff
changeset
|
432 } |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 for (char * cur = disbuf; *cur != 0; cur++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 if (*cur == ',' || *cur == ' ') { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 *cur = '_'; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 } |
391
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
439 //save memory result |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
440 if (is_mem) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
441 if (reg_usage[Z80_A]) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
442 cur = push(cur, Z80_AF); |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
443 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
444 cur = ld_mema(cur, address); |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
445 if (reg_usage[Z80_A]) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
446 for (int reg = 0; reg < Z80_I; reg++) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
447 if (!reg_usage[reg]) { |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
448 cur = ld_rr8(cur, Z80_A, reg); |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
449 break; |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
450 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
451 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
452 cur = pop(cur, Z80_AF); |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
453 } |
3f4f2b7318a1
Check memory results in ztestgen
Mike Pavone <pavone@retrodev.com>
parents:
298
diff
changeset
|
454 } |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
455 |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 //halt |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 *(cur++) = 0x76; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 sprintf(pathbuf + strlen(pathbuf), "/%s.bin", disbuf); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 FILE * progfile = fopen(pathbuf, "wb"); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 fwrite(prog, 1, cur - prog, progfile); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 fclose(progfile); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 uint8_t should_skip(z80inst * inst) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 { |
619
3072fb746601
Added support for JR and JRcc in Z80 test generator
Michael Pavone <pavone@retrodev.com>
parents:
618
diff
changeset
|
467 return inst->op >= Z80_DJNZ || (inst->op >= Z80_LDI && inst->op <= Z80_CPDR) || inst->op == Z80_HALT |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 || inst->op == Z80_DAA || inst->op == Z80_RLD || inst->op == Z80_RRD || inst->op == Z80_NOP |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
469 || inst->op == Z80_DI || inst->op == Z80_EI; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
470 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 void z80_gen_all() |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 uint8_t inst[3]; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 for (int op = 0; op < 256; op++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
476 inst[0] = op; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 if (op == 0xCB) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 for (int subop = 0; subop < 256; subop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 if (!should_skip(z80_tbl_bit + subop)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 inst[1] = subop; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 z80_gen_test(z80_tbl_bit + subop, inst, 2); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
484 } else if(op == 0xDD) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 for (int ixop = 0; ixop < 256; ixop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
486 inst[1] = ixop; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 if (ixop == 0xCB) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
488 for (int subop = 0; subop < 256; subop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
489 if (!should_skip(z80_tbl_ix_bit + subop)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
490 inst[2] = subop; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
491 z80_gen_test(z80_tbl_ix_bit + subop, inst, 3); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
492 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
493 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
494 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 if (!should_skip(z80_tbl_ix + ixop)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 z80_gen_test(z80_tbl_ix + ixop, inst, 2); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 } else if(op == 0xED) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
501 for (int subop = 0; subop < sizeof(z80_tbl_extd)/sizeof(z80inst); subop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 if (!should_skip(z80_tbl_extd + subop)) { |
296
f90aeea98e53
Fix encoding of "extended" instructions in Z80 test generator
Mike Pavone <pavone@retrodev.com>
parents:
292
diff
changeset
|
503 inst[1] = subop + 0x40; |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
504 z80_gen_test(z80_tbl_extd + subop, inst, 2); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
506 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
507 } else if(op == 0xFD) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 for (int iyop = 0; iyop < 256; iyop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
509 inst[1] = iyop; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 if (iyop == 0xCB) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
511 for (int subop = 0; subop < 256; subop++) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
512 if (!should_skip(z80_tbl_iy_bit + subop)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
513 inst[2] = subop; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
514 z80_gen_test(z80_tbl_iy_bit + subop, inst, 3); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
515 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
516 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
517 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
518 if (!should_skip(z80_tbl_iy + iyop)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
519 z80_gen_test(z80_tbl_iy + iyop, inst, 2); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
520 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
523 } else { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
524 if (!should_skip(z80_tbl_a + op)) { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
525 z80_gen_test(z80_tbl_a + op, inst, 1); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
526 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
527 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 } |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
530 |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
531 int main(int argc, char ** argv) |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
532 { |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
533 z80_gen_all(); |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
534 return 0; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
535 } |