From 752caf8e215d96f2a1a7e26ebd66adddc8e4083d Mon Sep 17 00:00:00 2001 From: Peter Tattam Date: Thu, 13 Mar 2003 00:49:20 +0000 Subject: [PATCH] x86-64 emulation Fixed PUSHFW/POPFW for 64 bit mode. (was doing PUSHFQ/POPFQ) --- bochs/cpu/flag_ctrl.cc | 43 +++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/bochs/cpu/flag_ctrl.cc b/bochs/cpu/flag_ctrl.cc index 23e9dba7b..8d5d8673e 100644 --- a/bochs/cpu/flag_ctrl.cc +++ b/bochs/cpu/flag_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: flag_ctrl.cc,v 1.14 2002-10-24 21:05:42 bdenney Exp $ +// $Id: flag_ctrl.cc,v 1.15 2003-03-13 00:49:20 ptrumpet Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -153,7 +153,17 @@ BX_CPU_C::PUSHF_Fv(bxInstruction_c *i) #if BX_CPU_LEVEL >= 3 #if BX_SUPPORT_X86_64 if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) { - push_64(read_eflags() & 0x00fcffff); + if (i->os32L()) { + push_64(read_eflags() & 0x00fcffff); + } + else + { + Bit16u flags16; + + flags16 = read_flags(); + write_virtual_word(BX_SEG_REG_SS, RSP-2, &flags16); + RSP -= 2; + } } else #endif @@ -180,13 +190,28 @@ BX_CPU_C::POPF_Fv(bxInstruction_c *i) if (BX_CPU_THIS_PTR cpu_mode == BX_MODE_LONG_64) { Bit64u flags64; - pop_64(&flags64); - flags32 = flags64; - changeMask |= 0x240000; // ID,AC - if (CPL==0) - changeMask |= (3<<12); // IOPL - if (CPL <= BX_CPU_THIS_PTR get_IOPL()) - changeMask |= (1<<9); // IF + if (i->os32L()) { + pop_64(&flags64); + flags32 = flags64; + changeMask |= 0x240000; // ID,AC + if (CPL==0) + changeMask |= (3<<12); // IOPL + if (CPL <= BX_CPU_THIS_PTR get_IOPL()) + changeMask |= (1<<9); // IF + } + else + { + Bit16u flags16; + + read_virtual_word(BX_SEG_REG_SS, RSP, &flags16); + + RSP += 2; + flags32 = flags16; + if (CPL==0) + changeMask |= (3<<12); // IOPL + if (CPL <= BX_CPU_THIS_PTR get_IOPL()) + changeMask |= (1<<9); // IF + } } else #endif // #if BX_SUPPORT_X86_64