Skip to content

Commit

Permalink
Add accurate emulation of MEMPTR in the I/O block instructions accord…
Browse files Browse the repository at this point in the history
…ing to the latest discovery.
  • Loading branch information
redcode committed Dec 3, 2023
1 parent 9c36597 commit 1ef7f5a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ This set of programs is intended to help the emulator authors to reach the desir
</table>
</details>
<details>
<summary>Results (v1.2)</summary>
<summary>Results (v1.2a)</summary>
<table>
<tr>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80full.tap</b>
</a>
<br>
<sup>Tests all flags and registers.</sup>
</td>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80doc.tap</b>
</a>
Expand All @@ -132,23 +132,23 @@ This set of programs is intended to help the emulator authors to reach the desir
</tr>
<tr>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20Full.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20Full.gif">
</td>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20Doc.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20Doc.gif">
</td>
</tr>
<tr>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80flags.tap</b>
</a>
<br>
<sup>Tests all flags, ignores registers.</sup>
</td>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80docflags.tap</b>
</a>
Expand All @@ -158,23 +158,23 @@ This set of programs is intended to help the emulator authors to reach the desir
</tr>
<tr>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20Flags.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20Flags.gif">
</td>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20Doc%20Flags.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20Doc%20Flags.gif">
</td>
</tr>
<tr>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80ccf.tap</b>
</a>
<br>
<sup>Tests all flags after executing <code>ccf</code> after each instruction tested.</sup>
</td>
<td align="center" valign="top">
<a href="https://web.archive.org/web/20221202204115id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2.zip">
<a href="https://web.archive.org/web/20231202140745id_/http://zxds.raxoft.cz/taps/misc/z80test-1.2a.zip">
<img src="https://zxe.io/software/Z80/assets/images/tap.svg" width="96"><br>
<b>z80memptr.tap</b>
</a>
Expand All @@ -184,10 +184,10 @@ This set of programs is intended to help the emulator authors to reach the desir
</tr>
<tr>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20CCF.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20CCF.gif">
</td>
<td align="center" valign="top">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2%20%282022-01-26%29%28Rak,%20Patrik%29%20-%20MEMPTR.gif">
<img src="https://zxe.io/software/Z80/tests/screenshots/ZX%20Spectrum/Zilog%20Z80%20CPU%20Test%20Suite%20v1.2a%20%282023-12-02%29%28Rak,%20Patrik%29%20-%20MEMPTR.gif">
</td>
</tr>
</table>
Expand Down
16 changes: 9 additions & 7 deletions sources/Z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,16 +962,14 @@ static Z_ALWAYS_INLINE zuint8 m(Z80 *self, zuint8 offset, zuint8 value)
PF_PARITY(p ^ ((B + 1) & 7))) \
: PF_PARITY(p ^ (B & 7)))); \
\
MEMPTR = PC + 1; \
return 21; \
} \
\
FLAGS = ZF | /* ZF = 1; SF, YF, XF = 0 */ \
hcf | /* HF, CF = T > 255 */ \
PF_PARITY(p) | /* PF = ((T & 7) ^ Bo).parity */ \
nf; /* NF = IO.7 */ \
\
PC += 2; \
return 16
nf /* NF = IO.7 */


#define INXR(hl_operator, memptr_operator) \
Expand All @@ -984,7 +982,9 @@ static Z_ALWAYS_INLINE zuint8 m(Z80 *self, zuint8 offset, zuint8 value)
t = (zuint)io + (zuint8)(MEMPTR = BC memptr_operator 1); \
hcf = (t > 255) ? HCF : 0; \
p = (t & 7) ^ --B; \
INXR_OTXR(io)
INXR_OTXR(io); \
PC += 2; \
return 16


#define OTXR(hl_operator, memptr_operator) \
Expand All @@ -994,9 +994,11 @@ static Z_ALWAYS_INLINE zuint8 m(Z80 *self, zuint8 offset, zuint8 value)
zuint8 hcf = (t > 255) ? HCF : 0; \
zuint8 p = (t & 7) ^ --B; \
\
MEMPTR = BC memptr_operator 1; \
OUT(BC, io); \
INXR_OTXR(io)
INXR_OTXR(io); \
MEMPTR = BC memptr_operator 1; \
PC += 2; \
return 16


#define SET_HALT_LINE(state) \
Expand Down
16 changes: 8 additions & 8 deletions sources/test-Z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ static Test const tests[22] = {
{"Zilog Z80 CPU Test Suite v1.0 (2012-12-08)(Rak, Patrik)[!].zip", "z80test-1.0/z80docflags.tap", C(0, 2110B9B1) /* 554,744,241 */, 13758, 91, 13666, 0x8000, 0x7003, TEST_FORMAT_RAK, 156, 32},
{"Zilog Z80 CPU Test Suite v1.0 (2012-12-08)(Rak, Patrik)[!].zip", "z80test-1.0/z80ccf.tap", C(0, 23AB74CA) /* 598,439,114 */, 14219, 91, 14127, 0x8000, 0x7003, TEST_FORMAT_RAK, 156, 32},
{"Zilog Z80 CPU Test Suite v1.0 (2012-12-08)(Rak, Patrik)[!].zip", "z80test-1.0/z80memptr.tap", C(0, 215CF3BD) /* 559,739,837 */, 13758, 91, 13666, 0x8000, 0x7003, TEST_FORMAT_RAK, 156, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80full.tap", C(0, 4382DC6A) /* 1,132,649,578 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80doc.tap", C(0, 43EE72CE) /* 1,139,700,430 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80flags.tap", C(0, 212F17D5) /* 556,734,421 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80docflags.tap", C(0, 2152FFDA) /* 559,087,578 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80ccf.tap", C(0, 23F34E43) /* 603,147,843 */, 14875, 91, 14783, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip", "z80test-1.2/z80memptr.tap", C(0, 219FC276) /* 564,118,134 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}};
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80full.tap", C(0, 4382DC6A) /* 1,132,649,578 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80doc.tap", C(0, 43EE72CE) /* 1,139,700,430 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80flags.tap", C(0, 212F17D5) /* 556,734,421 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80docflags.tap", C(0, 2152FFDA) /* 559,087,578 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80ccf.tap", C(0, 23F34E43) /* 603,147,843 */, 14875, 91, 14783, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32},
{"Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip", "z80test-1.2a/z80memptr.tap", C(0, 219FC276) /* 564,118,134 */, 14390, 91, 14298, 0x8000, 0x7003, TEST_FORMAT_RAK, 164, 32}};

#undef C

Expand Down Expand Up @@ -179,7 +179,7 @@ static zusize cycles, lines, cursor_x, columns;

/*-----------------------------------------------------------------------------.
| `zx_spectrum_print_hook_address` contains the address of the hook that |
| intercepts the routine called by the test to print characters. When a TAB |
| intercepts the routine called by the test to print characters. When a <TAB> |
| character (17h) is printed, the `zx_spectrum_tab` counter is set to 2 to |
| indicate that it is necessary to process the incoming <TAB n> and <TAB STOP> |
| bytes before continuing to print characters. `zx_spectrum_bad_character` is |
Expand Down Expand Up @@ -777,7 +777,7 @@ int main(int argc, char **argv)
" 13 Tests documented flags only, ignores registers.\n"
" 14 Tests all flags after executing `ccf` after each instruction.\n"
" 15 Tests all flags after executing `bit N,(hl)` after each instruction.\n"
" Zilog Z80 CPU Test Suite v1.2 ~ ZX Spectrum ~ Rak, Patrik (2022-01-26):\n"
" Zilog Z80 CPU Test Suite v1.2a ~ ZX Spectrum ~ Rak, Patrik (2023-12-02):\n"
" 16 Tests all flags and registers.\n"
" 17 Tests all registers, but only officially documented flags.\n"
" 18 Tests all flags, ignores registers.\n"
Expand Down
2 changes: 1 addition & 1 deletion support/software.sha3-512
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ BAA29B8D799F59C4B7D485AA9CC7152172623EC4C827372F4E12CF0AB18BB7F7E7AD449BC59615F5
4667E8CF1E4171842101EAC56BBB6893059E37B4B52ECA22A9C7A4DB1DB668439FA1E8BD77EFE6E9496EC7CD7B1F420BA45672D52A045E1E09C7425D9850E85A ZX Spectrum/Z80 Instruction Set Exerciser for Spectrum 2 v0.1 (2012-11-27)(Rak, Patrik)[!].zip
BB1DCE3187FBF5EA871FE41EB76AE7E0C94D08136FF4D8E756E2624DA589AAE69CAD074EB43CBFB9E2B9E0D2CC505343D9804EDCDE3CEA1FB1881DCBF5C865B0 ZX Spectrum/Z80 Test Suite (2008)(Woodmass, Mark)[!].tap
13F24211FDC8053204DC8C6224A5FE99063AEC840C9A9A0225DC1CDB20FE0C119EB570F50A5373D2F2CC22FEDB96286721DA67DBC8A9ABA8EBDE14E539EE2C43 ZX Spectrum/Zilog Z80 CPU Test Suite v1.0 (2012-12-08)(Rak, Patrik)[!].zip
025C5CD9D7F782BC6053A009DF11B89A0120AC3BB63F979B7219EC195EDA9183DB0A9A9D2BDC2C0CBA236F9E6610591311A4FA2A7DCFEFAC33E5F20987281BD3 ZX Spectrum/Zilog Z80 CPU Test Suite v1.2 (2022-01-26)(Rak, Patrik)[!].zip
DD58528572CA0BF2F0FCA6191F339A091D78CBD1A73A4FEE74726F99A6B686A27E75F9882E178015116F4AF28C7E3FF2D4557484F53D6963FE95F47F4653DC28 ZX Spectrum/Zilog Z80 CPU Test Suite v1.2a (2023-12-02)(Rak, Patrik)[!].zip

0 comments on commit 1ef7f5a

Please sign in to comment.