svn commit: r268102 - stable/8/sys/contrib/x86emu

Xin LI delphij at FreeBSD.org
Tue Jul 1 16:01:49 UTC 2014


Author: delphij
Date: Tue Jul  1 16:01:48 2014
New Revision: 268102
URL: http://svnweb.freebsd.org/changeset/base/268102

Log:
  MFC r267372-267374: fix various misimplementation of instructions.
  
  Submitted by:	Wolf Ramovsky <wolf.ramovsky gmail.com>

Modified:
  stable/8/sys/contrib/x86emu/x86emu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/contrib/   (props changed)

Modified: stable/8/sys/contrib/x86emu/x86emu.c
==============================================================================
--- stable/8/sys/contrib/x86emu/x86emu.c	Tue Jul  1 16:00:48 2014	(r268101)
+++ stable/8/sys/contrib/x86emu/x86emu.c	Tue Jul  1 16:01:48 2014	(r268102)
@@ -2131,21 +2131,24 @@ x86emuOp_mov_word_RM_SR(struct x86emu *e
 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;
+	}
 }
 
 /*
@@ -3709,12 +3712,19 @@ x86emuOp_out_word_IMM_AX(struct x86emu *
 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;
+	}
 }
 
 /*
@@ -5566,6 +5576,7 @@ x86emuOp2_32_movsx_byte_R_RM(struct x86e
 {
 	uint32_t *destreg;
 
+	fetch_decode_modrm(emu);
 	destreg = decode_rh_long_register(emu);
 	*destreg = (int32_t)(int8_t)decode_and_fetch_byte(emu);
 }


More information about the svn-src-stable-8 mailing list