From 549eb703245583d2f5d7eeb926d144fe8701b491 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Sun, 3 Aug 2003 16:44:53 +0000 Subject: [PATCH] Committed CPU fixes from Vitaly Vorobyov: [x] fixed bug in int01 (opcode 0xF1) emulation [x] fixed bug in x86 debugger with dr0-dr3 registers Committed disassembler bugfix from Dirk Thierbach: [x] fixed bug in relative addresses in Jmp, Jcc, Call and so on --- bochs/cpu/proc_ctrl.cc | 13 +++++++++---- bochs/cpu/soft_int.cc | 6 +++--- bochs/cpu/stack_pro.cc | 4 ++-- bochs/disasm/dis_groups.cc | 18 +++++++++--------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index c9947c603..3a3f265cf 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: proc_ctrl.cc,v 1.72 2003-06-20 08:58:12 sshwarts Exp $ +// $Id: proc_ctrl.cc,v 1.73 2003-08-03 16:44:53 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -73,7 +73,7 @@ BX_CPU_C::HLT(bxInstruction_c *i) BX_PANIC(("HALT instruction encountered in the BIOS ROM")); if (CPL!=0) { - BX_INFO(("HLT(): CPL!=0")); +// BX_INFO(("HLT(): CPL!=0")); exception(BX_GP_EXCEPTION, 0, 0); return; } @@ -175,8 +175,9 @@ BX_CPU_C::MOV_DdRd(bxInstruction_c *i) #else Bit32u val_32; - if (v8086_mode()) BX_PANIC(("MOV_DdRd: v8086 mode unsupported")); - + if (v8086_mode()) { + exception(BX_GP_EXCEPTION, 0, 0); + } /* NOTES: * 32bit operands always used * r/m field specifies general register @@ -290,6 +291,10 @@ BX_CPU_C::MOV_DdRd(bxInstruction_c *i) // Even bits 11,10 are changeable though reserved. BX_CPU_THIS_PTR dr7 = (val_32 & 0xffff2fff) | 0x00000400; #endif + // if we have breakpoints enabled then we must check + // breakpoints condition in cpu loop + if(BX_CPU_THIS_PTR dr7 & 0xff) + BX_CPU_THIS_PTR async_event = 1; break; default: BX_PANIC(("MOV_DdRd: control register index out of range")); diff --git a/bochs/cpu/soft_int.cc b/bochs/cpu/soft_int.cc index 1c7ad6b3e..51bf05041 100644 --- a/bochs/cpu/soft_int.cc +++ b/bochs/cpu/soft_int.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soft_int.cc,v 1.16 2003-05-15 16:41:16 sshwarts Exp $ +// $Id: soft_int.cc,v 1.17 2003-08-03 16:44:53 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -89,9 +89,9 @@ BX_CPU_C::INT1(bxInstruction_c *i) #if BX_EXTERNAL_DEBUGGER trap_debugger(0); -#else - interrupt(1, 1, 0, 0); #endif + + interrupt(1, 1, 0, 0); BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_INT, BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, EIP); diff --git a/bochs/cpu/stack_pro.cc b/bochs/cpu/stack_pro.cc index dc4c2e0cf..90c1dd67c 100644 --- a/bochs/cpu/stack_pro.cc +++ b/bochs/cpu/stack_pro.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: stack_pro.cc,v 1.14 2003-03-02 23:59:09 cbothamy Exp $ +// $Id: stack_pro.cc,v 1.15 2003-08-03 16:44:53 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -52,7 +52,7 @@ BailBigRSP("push_16"); #endif temp_ESP = SP; if (!can_push(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache, temp_ESP, 2)) { - BX_PANIC(("push_16(): push outside stack limits")); + BX_DEBUG(("push_16(): push outside stack limits")); exception(BX_SS_EXCEPTION, 0, 0); return; } diff --git a/bochs/disasm/dis_groups.cc b/bochs/disasm/dis_groups.cc index f979dbc53..2f482e6dd 100644 --- a/bochs/disasm/dis_groups.cc +++ b/bochs/disasm/dis_groups.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: dis_groups.cc,v 1.8 2003-01-21 13:23:47 cbothamy Exp $ +// $Id: dis_groups.cc,v 1.9 2003-08-03 16:44:53 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -418,12 +418,12 @@ bx_disassemble_c::Av(void) { if (db_32bit_opsize) { Bit32s imm32; - imm32 = fetch_dword(); + imm32 = (Bit32s) fetch_dword(); dis_sprintf("%08x", (unsigned) (imm32 + db_eip)); } else { Bit16s imm16; - imm16 = fetch_word(); + imm16 = (Bit16s) fetch_word(); dis_sprintf("%04x", (unsigned) ((imm16 + db_eip) & 0xFFFF)); } } @@ -522,17 +522,17 @@ bx_disassemble_c::Jv(void) { #if BX_CPU_LEVEL > 2 if (db_32bit_opsize) { - Bit32u imm32; + Bit32s imm32; /* JMP rel32 is signed */ - imm32 = fetch_dword(); + imm32 = (Bit32s) fetch_dword(); dis_sprintf("%08x", (unsigned) (imm32 + db_eip)); } else #endif { - Bit16u imm16; + Bit16s imm16; /* JMP rel16 is signed */ - imm16 = fetch_word(); + imm16 = (Bit16s) fetch_word(); dis_sprintf("%04x", (unsigned) ((imm16 + db_eip) & 0xFFFF)); } } @@ -591,9 +591,9 @@ bx_disassemble_c::Ib(void) void bx_disassemble_c::Jb(void) { - Bit8u imm8; + Bit8s imm8; /* JMP rel8 is signed */ - imm8 = fetch_byte(); + imm8 = (Bit8s) fetch_byte(); #if BX_CPU_LEVEL > 2 if (db_32bit_opsize) { dis_sprintf("%08x", (unsigned) (imm8 + db_eip));