From 79d183e85f497d7c840bdcf9ec10f12ee6f98f9b Mon Sep 17 00:00:00 2001 From: Xin LI Date: Wed, 11 Jun 2014 20:31:41 +0000 Subject: [PATCH] Fix decoding of LEA when address-size prefix (67h) is present. This is loosly based on Xorg changeset f57bc0e by Christian Zander. Submitted by: Wolf Ramovsky via core (peter) MFC after: 2 weeks --- sys/contrib/x86emu/x86emu.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/contrib/x86emu/x86emu.c b/sys/contrib/x86emu/x86emu.c index 45c6373076e3..60c54120cf3b 100644 --- a/sys/contrib/x86emu/x86emu.c +++ b/sys/contrib/x86emu/x86emu.c @@ -2151,21 +2151,24 @@ x86emuOp_mov_word_RM_SR(struct x86emu *emu) static void x86emuOp_lea_word_R_M(struct x86emu *emu) { - uint16_t *srcreg; uint32_t destoffset; -/* - * TODO: Need to handle address size prefix! - * - * lea eax,[eax+ebx*2] ?? - */ fetch_decode_modrm(emu); if (emu->cur_mod == 3) x86emu_halt_sys(emu); - srcreg = decode_rh_word_register(emu); destoffset = decode_rl_address(emu); - *srcreg = (uint16_t) destoffset; + if (emu->x86.mode & SYSMODE_PREFIX_ADDR) { + uint32_t *srcreg; + + srcreg = decode_rh_long_register(emu); + *srcreg = (uint32_t) destoffset; + } else { + uint16_t *srcreg; + + srcreg = decode_rh_word_register(emu); + *srcreg = (uint16_t) destoffset; + } } /*