# HG changeset patch # User Michael Pavone # Date 1431918207 25200 # Node ID b707a8ddc202853708dcce9ed6f9a1b351419eb6 # Parent 1c2020d3e2758e2ecbef0967009b0a3df127d056 Make sure z80_save_reg does nothing when there is no register in the reg field of the instruction. This fixes a bug that corrupted SP in the MDEM 2011 demo diff -r 1c2020d3e275 -r b707a8ddc202 z80_to_x86.c --- a/z80_to_x86.c Sun May 17 19:14:41 2015 -0700 +++ b/z80_to_x86.c Sun May 17 20:03:27 2015 -0700 @@ -81,6 +81,9 @@ void z80_save_reg(z80inst * inst, z80_options * opts) { code_info *code = &opts->gen.code; + if (inst->reg == Z80_USE_IMMED || inst->reg == Z80_UNUSED) { + return; + } if (inst->reg == Z80_IYH) { if ((inst->addr_mode & 0x1F) == Z80_REG && inst->ea_reg == Z80_IYL) { ror_ir(code, 8, opts->regs[Z80_IY], SZ_W);