summaryrefslogtreecommitdiff
path: root/z80_to_x86.c
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-04-29 22:52:05 -0700
committerMike Pavone <pavone@retrodev.com>2013-04-29 22:52:05 -0700
commitce28b14ff4a8f56a7f9653db90a1aa685714dda6 (patch)
tree2f79df0fa7ee7a5be88b934f7140c3a24c20a33c /z80_to_x86.c
parent575a21e0f42a83b24c2e96339e3d741ceb21a55d (diff)
Properly handle wrapping around to 0 in translate_z80_stream
Diffstat (limited to 'z80_to_x86.c')
-rw-r--r--z80_to_x86.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/z80_to_x86.c b/z80_to_x86.c
index 88e0120..41730f5 100644
--- a/z80_to_x86.c
+++ b/z80_to_x86.c
@@ -1345,7 +1345,7 @@ void translate_z80_stream(z80_context * context, uint32_t address)
opts->code_end = opts->cur_code + size;
jmp(opts->cur_code, opts->cur_code);
}
- if (address > 0x4000 & address < 0x8000) {
+ if (address > 0x4000 && address < 0x8000) {
opts->cur_code = xor_rr(opts->cur_code, RDI, RDI, SZ_D);
opts->cur_code = call(opts->cur_code, (uint8_t *)exit);
break;
@@ -1366,7 +1366,12 @@ void translate_z80_stream(z80_context * context, uint32_t address)
z80_map_native_address(context, address, opts->cur_code, next-encoded, after - opts->cur_code);
opts->cur_code = after;
address += next-encoded;
- encoded = next;
+ if (address > 0xFFFF) {
+ address &= 0xFFFF;
+
+ } else {
+ encoded = next;
+ }
} while (!(inst.op == Z80_RET || inst.op == Z80_RETI || inst.op == Z80_RETN || inst.op == Z80_JP || (inst.op == Z80_NOP && inst.immed == 42)));
process_deferred(&opts->deferred, context, (native_addr_func)z80_get_native_address);
if (opts->deferred) {