Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/common/lib/libx86emu Fix decoding of LEA when address-size p...



details:   https://anonhg.NetBSD.org/src/rev/832e3f2cdfbe
branches:  trunk
changeset: 797941:832e3f2cdfbe
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Aug 04 21:40:11 2014 +0000

description:
Fix decoding of LEA when address-size prefix (67h) is present.

>From Wolf Ramovsky via FreeBSD, loosly based on Xorg changeset f57bc0e
by Christian Zander.

diffstat:

 common/lib/libx86emu/x86emu.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (42 lines):

diff -r f71e61355c46 -r 832e3f2cdfbe common/lib/libx86emu/x86emu.c
--- a/common/lib/libx86emu/x86emu.c     Mon Aug 04 20:59:19 2014 +0000
+++ b/common/lib/libx86emu/x86emu.c     Mon Aug 04 21:40:11 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86emu.c,v 1.8 2014/08/04 19:19:02 joerg Exp $ */
+/*     $NetBSD: x86emu.c,v 1.9 2014/08/04 21:40:11 joerg Exp $ */
 
 /****************************************************************************
 *
@@ -2091,21 +2091,24 @@
 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;
+       }
 }
 /****************************************************************************
 REMARKS:



Home | Main Index | Thread Index | Old Index