Incorrect arithmetic ops & addressing
A Z80 emulation library
Status: Beta
Brought to you by:
ggambett
16 bit arithmetic operations are coded with 8 bit data
types, so results are completely incorrect.
Sign extension in JR and DJNZ is.... maybe not
incorrect, but coded in an excessively complicated way;
it should be enough to cast from 'byte' to 'char', and
then to 'int'.
Indexed addressing offsets are not correctly
calculated: addresses are 16 bit wide, UNSIGNED, and
offsets are 8 bit wide, SIGNED. As sign extension is
not being done in those cases, negative offsets are
incorrectly calculated.
Mmmm.... are you sure this library has ever been useful???
Logged In: YES
user_id=517400
> Mmmm.... are you sure this library has ever been
useful???
Not exactly this code, but most if it comes from fairly solid
and working code. I'll check your reports, thanks!
Logged In: YES
user_id=29214
The original poster is basically correct; a significant
proportion of the opcodes are emulated incorrectly.
Attached is a small test program which runs the test suite
as supplied with Fuse
<http://sourceforge.net/projects/fuse-emulator/>; you'll
need the z80/tests directory from there.
Currently, 645 out of 1307 tests.