Skip to content

Commit dc0c79b

Browse files
committed
Add optional precomputed values in daa (configurable at compile time).
1 parent 1efc6bb commit dc0c79b

File tree

4 files changed

+233
-51
lines changed

4 files changed

+233
-51
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ table of precomputed values (this is for benchmarks, DO NOT ENABLE in \
121121
production builds)."
122122
NO)
123123

124+
option(${PROJECT_NAME}_WITH_PRECOMPUTED_DAA
125+
"${PROJECT_NAME}: \
126+
Use a table of precomputed values in the `daa` instruction (this is for \
127+
benchmarks, DO NOT ENABLE in production builds)."
128+
NO)
129+
124130
option(${PROJECT_NAME}_WITH_Q
125131
"${PROJECT_NAME}: \
126132
Build the implementation of Q."
@@ -220,6 +226,7 @@ target_compile_definitions(
220226
$<$<BOOL:${${PROJECT_NAME}_WITH_FULL_IM0}>:Z80_WITH_FULL_IM0>
221227
$<$<BOOL:${${PROJECT_NAME}_WITH_IM0_RETX_NOTIFICATIONS}>:Z80_WITH_IM0_RETX_NOTIFICATIONS>
222228
$<$<BOOL:${${PROJECT_NAME}_WITH_PARITY_COMPUTATION}>:Z80_WITH_PARITY_COMPUTATION>
229+
$<$<BOOL:${${PROJECT_NAME}_WITH_PRECOMPUTED_DAA}>:Z80_WITH_PRECOMPUTED_DAA>
223230
$<$<BOOL:${${PROJECT_NAME}_WITH_Q}>:Z80_WITH_Q>
224231
$<$<BOOL:${${PROJECT_NAME}_WITH_SPECIAL_RESET}>:Z80_WITH_SPECIAL_RESET>
225232
$<$<BOOL:${${PROJECT_NAME}_WITH_UNOFFICIAL_RETI}>:Z80_WITH_UNOFFICIAL_RETI>

HISTORY

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,44 @@ Changes:
7272
(Zilog Z80 NMOS). If enabled at compile-time and configured at runtime, the
7373
P/V flag will be reset if an INT is accepted during the execution of these
7474
instructions.
75-
37. Increased granularity. The emulator can now stop directly after fetching a
75+
37. Added an optional implementation of the parity calculation for the P/V flag
76+
that performs the actual computation instead of using a table of precomputed
77+
values.
78+
38. Added an optional implementation of the `daa` instruction that uses a table
79+
of precomputed values.
80+
39. Increased granularity. The emulator can now stop directly after fetching a
7681
prefix DDh or FDh if it runs out of clock cycles. This also works during the
7782
INT response in mode 0.
78-
38. Reimplemented the HALT state. The emulation should now be fully accurate.
83+
40. Reimplemented the HALT state. The emulation should now be fully accurate.
7984
HALTskip optimization is also supported.
80-
39. Fixed a bug in the `sll` instruction.
81-
40. Fixed a bug in the `INX` and `OUTX` macros affecting the S and N flags.
82-
41. Fixed a bug in the `OUTX` macro affecting the MSByte of the port number.
83-
42. Fixed the clock cycles of the `dec XY` and `in (c)` instructions.
84-
43. Fixed the `read_16` function so that the order of the memory read operations
85+
41. Fixed a bug in the `sll` instruction.
86+
42. Fixed a bug in the `INX` and `OUTX` macros affecting the S and N flags.
87+
43. Fixed a bug in the `OUTX` macro affecting the MSByte of the port number.
88+
44. Fixed the clock cycles of the `dec XY` and `in (c)` instructions.
89+
45. Fixed the `read_16` function so that the order of the memory read operations
8590
is not determined by the order in which the compiler evaluates expressions.
86-
44. Fixed the order in which the memory write operations are performed when the
91+
46. Fixed the order in which the memory write operations are performed when the
8792
SP register is involved. This affects the NMI response, the INT response in
8893
modes 1 and 2, and the following instructions: `ex (sp),{hl|XY}`, `push TT`,
8994
`push XY`, `call WORD`, `call Z,WORD` and `rst N`.
90-
45. Fixed the handling of illegal instructions to avoid stack overflows in long
95+
47. Fixed the handling of illegal instructions to avoid stack overflows in long
9196
sequences of DDh/FDh prefixes.
92-
46. Fixed several implicit conversions to avoid warnings about loss of sign and
97+
48. Fixed several implicit conversions to avoid warnings about loss of sign and
9398
precision.
94-
47. Fixed some bitwise operations to avoid undefined behavior and arithmetic
99+
49. Fixed some bitwise operations to avoid undefined behavior and arithmetic
95100
right shifts on signed integers.
96-
48. Fixed violations of the C standard in several identifiers.
97-
49. Renamed the 8-bit register lists: X/Y to J/K; J/K and P/Q to O/P.
98-
50. Replaced all P/V overflow computation functions with a single, faster macro.
99-
51. Replaced all register resolution functions with macros.
100-
52. Replaced all `ld {J,K|O,P}` instructions that have the same destination and
101+
50. Fixed violations of the C standard in several identifiers.
102+
51. Renamed the 8-bit register lists: X/Y to J/K; J/K and P/Q to O/P.
103+
52. Replaced all P/V overflow computation functions with a single, faster macro.
104+
53. Replaced all register resolution functions with macros.
105+
54. Replaced all `ld {J,K|O,P}` instructions that have the same destination and
101106
source register with NOPs. In addition, the "illegal" forms of the following
102107
instructions are now executed without using the illegal instruction handler:
103108
`ld O,P`, `ld O,BYTE`, `U [a,]P` and `V O`.
104-
53. Optimizations in flag computation and condition evaluation.
105-
54. New source code comments and improvements to existing ones.
106-
55. Improved code aesthetics.
107-
56. Other improvements, optimizations and minor changes.
109+
55. Optimizations in flag computation and condition evaluation.
110+
56. New source code comments and improvements to existing ones.
111+
57. Improved code aesthetics.
112+
58. Other improvements, optimizations and minor changes.
108113

109114

110115
Z80 v0.1 (2018-11-10)

documentation/VersionHistory.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,28 @@ This is an important update that addresses a number of issues and also includes
4747
34. Added optional emulation of Q. If enabled at compile-time, the ``ccf`` and ``scf`` instructions will produce a correct value of F.
4848
35. Added emulation of the ``out (c),255`` instruction (Zilog Z80 CMOS).
4949
36. Added optional emulation of the bug affecting the ``ld a,{i|r}`` instructions (Zilog Z80 NMOS). If enabled at compile-time and configured at runtime, the P/V flag will be reset if an INT is accepted during the execution of these instructions.
50-
37. Increased granularity. The emulator can now stop directly after fetching a prefix ``DDh`` or ``FDh`` if it runs out of clock cycles. This also works during the INT response in mode 0.
51-
38. Reimplemented the HALT state. The emulation should now be fully accurate. HALTskip optimization is also supported.
52-
39. Fixed a bug in the ``sll`` instruction.
53-
40. Fixed a bug in the ``INX`` and ``OUTX`` macros affecting the S and N flags.
54-
41. Fixed a bug in the ``OUTX`` macro affecting the MSByte of the port number.
55-
42. Fixed the clock cycles of the ``dec XY`` and ``in (c)`` instructions.
56-
43. Fixed the ``read_16`` function so that the order of the memory read operations is not determined by the order in which the compiler evaluates expressions.
57-
44. Fixed the order in which the memory write operations are performed when the SP register is involved. This affects the NMI response, the INT response in modes 1 and 2, and the following instructions: ``ex (sp),{hl|XY}``, ``push TT``, ``push XY``, ``call WORD``, ``call Z,WORD`` and ``rst N``.
58-
45. Fixed the handling of illegal instructions to avoid stack overflows in long sequences of ``DDh/FDh`` prefixes.
59-
46. Fixed several implicit conversions to avoid warnings about loss of sign and precision.
60-
47. Fixed some bitwise operations to avoid undefined behavior and arithmetic right shifts on signed integers.
61-
48. Fixed violations of the C standard in several identifiers.
62-
49. Renamed the 8-bit register lists: ``X/Y`` to ``J/K``; ``J/K`` and ``P/Q`` to ``O/P``.
63-
50. Replaced all P/V overflow computation functions with a single, faster macro.
64-
51. Replaced all register resolution functions with macros.
65-
52. Replaced all ``ld {J,K|O,P}`` instructions that have the same destination and source register with NOPs. In addition, the "illegal" forms of the following instructions are now executed without using the illegal instruction handler: ``ld O,P``, ``ld O,BYTE``, ``U [a,]P`` and ``V O``.
66-
53. Optimizations in flag computation and condition evaluation.
67-
54. New source code comments and improvements to existing ones.
68-
55. Improved code aesthetics.
69-
56. Other improvements, optimizations and minor changes.
50+
37. Added an optional implementation of the parity calculation for the P/V flag that performs the actual computation instead of using a table of precomputed values.
51+
38. Added an optional implementation of the ``daa`` instruction that uses a table of precomputed values.
52+
39. Increased granularity. The emulator can now stop directly after fetching a prefix ``DDh`` or ``FDh`` if it runs out of clock cycles. This also works during the INT response in mode 0.
53+
40. Reimplemented the HALT state. The emulation should now be fully accurate. HALTskip optimization is also supported.
54+
41. Fixed a bug in the ``sll`` instruction.
55+
42. Fixed a bug in the ``INX`` and ``OUTX`` macros affecting the S and N flags.
56+
43. Fixed a bug in the ``OUTX`` macro affecting the MSByte of the port number.
57+
44. Fixed the clock cycles of the ``dec XY`` and ``in (c)`` instructions.
58+
45. Fixed the ``read_16`` function so that the order of the memory read operations is not determined by the order in which the compiler evaluates expressions.
59+
46. Fixed the order in which the memory write operations are performed when the SP register is involved. This affects the NMI response, the INT response in modes 1 and 2, and the following instructions: ``ex (sp),{hl|XY}``, ``push TT``, ``push XY``, ``call WORD``, ``call Z,WORD`` and ``rst N``.
60+
47. Fixed the handling of illegal instructions to avoid stack overflows in long sequences of ``DDh/FDh`` prefixes.
61+
48. Fixed several implicit conversions to avoid warnings about loss of sign and precision.
62+
49. Fixed some bitwise operations to avoid undefined behavior and arithmetic right shifts on signed integers.
63+
50. Fixed violations of the C standard in several identifiers.
64+
51. Renamed the 8-bit register lists: ``X/Y`` to ``J/K``; ``J/K`` and ``P/Q`` to ``O/P``.
65+
52. Replaced all P/V overflow computation functions with a single, faster macro.
66+
53. Replaced all register resolution functions with macros.
67+
54. Replaced all ``ld {J,K|O,P}`` instructions that have the same destination and source register with NOPs. In addition, the "illegal" forms of the following instructions are now executed without using the illegal instruction handler: ``ld O,P``, ``ld O,BYTE``, ``U [a,]P`` and ``V O``.
68+
55. Optimizations in flag computation and condition evaluation.
69+
56. New source code comments and improvements to existing ones.
70+
57. Improved code aesthetics.
71+
58. Other improvements, optimizations and minor changes.
7072

7173
Z80 v0.1
7274
========

0 commit comments

Comments
 (0)