Mercurial > repos > blastem
changeset 285:021aeb6df19b
Implement HALT (sort of tested)
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 04 May 2013 16:23:28 -0700 |
parents | ed7098f717d7 |
children | 872a8911e0f4 |
files | z80_to_x86.c zruntime.S |
diffstat | 2 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/z80_to_x86.c Sat May 04 15:58:15 2013 -0700 +++ b/z80_to_x86.c Sat May 04 16:23:28 2013 -0700 @@ -35,6 +35,7 @@ void z80_retrans_stub(); void z80_io_read(); void z80_io_write(); +void z80_halt(); uint8_t z80_size(z80inst * inst) { @@ -898,7 +899,13 @@ dst = zcycles(dst, 4 * inst->immed); } break; - //case Z80_HALT: + case Z80_HALT: + dst = zcycles(dst, 4); + dst = mov_ir(dst, address, SCRATCH1, SZ_W); + uint8_t * call_inst = dst; + dst = call(dst, (uint8_t *)z80_halt); + dst = jmp(dst, call_inst); + break; case Z80_DI: dst = zcycles(dst, 4); dst = mov_irdisp8(dst, 0, CONTEXT, offsetof(z80_context, iff1), SZ_B);
--- a/zruntime.S Sat May 04 15:58:15 2013 -0700 +++ b/zruntime.S Sat May 04 16:23:28 2013 -0700 @@ -71,6 +71,17 @@ zskip_sync: ret + .global z80_halt +z80_halt: + mov %edi, %r14d + sub %ebp, %r14d + and $0xFFFFFFFC, %r14d + add %r14d, %ebp + cmp %edi, %ebp + jnb z80_handle_cycle_limit_int + add $4, %ebp + jmp z80_handle_cycle_limit_int + .global z80_read_byte z80_read_byte: call z_inccycles