summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2014-08-04 21:41:44 +0000
committerjoerg <joerg@NetBSD.org>2014-08-04 21:41:44 +0000
commit465b0d3ef8dc52768488795fd0adec19fb7280a7 (patch)
tree0ac440a3634e2d5c8693cde8e18dc108dce32af4
parentc29b817121d4f267da9858857777cadb098580a2 (diff)
Fix decoding of near CALL when address-size prefix (67h) is present.
From Wolf Ramovsky via FreeBSD.
-rw-r--r--common/lib/libx86emu/x86emu.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/common/lib/libx86emu/x86emu.c b/common/lib/libx86emu/x86emu.c
index 5068af4d355..8c800112be5 100644
--- a/common/lib/libx86emu/x86emu.c
+++ b/common/lib/libx86emu/x86emu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: x86emu.c,v 1.9 2014/08/04 21:40:11 joerg Exp $ */
+/* $NetBSD: x86emu.c,v 1.10 2014/08/04 21:41:44 joerg Exp $ */
/****************************************************************************
*
@@ -3604,12 +3604,19 @@ Handles opcode 0xe8
static void
x86emuOp_call_near_IMM(struct X86EMU *emu)
{
- int16_t ip;
-
- ip = (int16_t) fetch_word_imm(emu);
- ip += (int16_t) emu->x86.R_IP; /* CHECK SIGN */
- push_word(emu, emu->x86.R_IP);
- emu->x86.R_IP = ip;
+ if (emu->x86.mode & SYSMODE_PREFIX_DATA) {
+ int32_t ip;
+ ip = (int32_t) fetch_long_imm(emu);
+ ip += (int32_t) emu->x86.R_EIP;
+ push_long(emu, emu->x86.R_EIP);
+ emu->x86.R_EIP = ip;
+ } else {
+ int16_t ip;
+ ip = (int16_t) fetch_word_imm(emu);
+ ip += (int16_t) emu->x86.R_IP; /* CHECK SIGN */
+ push_word(emu, emu->x86.R_IP);
+ emu->x86.R_IP = ip;
+ }
}
/****************************************************************************
REMARKS: