# HG changeset patch # User Mike Pavone # Date 1367558302 25200 # Node ID 3c054d977175c115c27f9485752b748f04d63c35 # Parent 6c2d7e003a55fb0ea213053ea03e52261ec2a230 Fix IX/IY displace modes. Fix check for registers requiring REX. diff -r 6c2d7e003a55 -r 3c054d977175 z80_to_x86.c --- a/z80_to_x86.c Thu May 02 21:54:04 2013 -0700 +++ b/z80_to_x86.c Thu May 02 22:18:22 2013 -0700 @@ -123,7 +123,7 @@ if (ea->base >= AH && ea->base <= BH) { if ((inst->addr_mode & 0x1F) == Z80_REG) { uint8_t other_reg = opts->regs[inst->ea_reg]; - if (other_reg > R8 || (other_reg >= RSP && other_reg <= RDI)) { + if (other_reg >= R8 || (other_reg >= RSP && other_reg <= RDI)) { //we can't mix an *H reg with a register that requires the REX prefix ea->base = opts->regs[z80_low_reg(inst->reg)]; dst = ror_ir(dst, 8, ea->base, SZ_W); @@ -150,7 +150,7 @@ } else if (opts->regs[inst->reg] >= AH && opts->regs[inst->reg] <= BH) { if ((inst->addr_mode & 0x1F) == Z80_REG) { uint8_t other_reg = opts->regs[inst->ea_reg]; - if (other_reg > R8 || (other_reg >= RSP && other_reg <= RDI)) { + if (other_reg >= R8 || (other_reg >= RSP && other_reg <= RDI)) { //we can't mix an *H reg with a register that requires the REX prefix dst = ror_ir(dst, 8, opts->regs[z80_low_reg(inst->reg)], SZ_W); } @@ -177,7 +177,7 @@ ea->base = opts->regs[inst->ea_reg]; if (ea->base >= AH && ea->base <= BH && inst->reg != Z80_UNUSED && inst->reg != Z80_USE_IMMED) { uint8_t other_reg = opts->regs[inst->reg]; - if (other_reg > R8 || (other_reg >= RSP && other_reg <= RDI)) { + if (other_reg >= R8 || (other_reg >= RSP && other_reg <= RDI)) { //we can't mix an *H reg with a register that requires the REX prefix ea->base = opts->regs[z80_low_reg(inst->ea_reg)]; dst = ror_ir(dst, 8, ea->base, SZ_W); @@ -244,6 +244,7 @@ dst = pop_r(dst, SCRATCH2); } } + ea->base = SCRATCH1; break; case Z80_UNUSED: ea->mode = MODE_UNUSED; @@ -262,7 +263,7 @@ dst = ror_ir(dst, 8, opts->regs[Z80_IY], SZ_W); } else if (inst->reg != Z80_UNUSED && inst->reg != Z80_USE_IMMED && opts->regs[inst->ea_reg] >= AH && opts->regs[inst->ea_reg] <= BH) { uint8_t other_reg = opts->regs[inst->reg]; - if (other_reg > R8 || (other_reg >= RSP && other_reg <= RDI)) { + if (other_reg >= R8 || (other_reg >= RSP && other_reg <= RDI)) { //we can't mix an *H reg with a register that requires the REX prefix dst = ror_ir(dst, 8, opts->regs[z80_low_reg(inst->ea_reg)], SZ_W); }