From aff775bce4edae0e389aea81d0a7b8c23e7f09ac Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Mon, 9 Jun 2008 19:35:59 +0000 Subject: [PATCH] Small code optimization --- bochs/cpu/fetchdecode.cc | 25 ++++++++------- bochs/cpu/fetchdecode64.cc | 63 ++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/bochs/cpu/fetchdecode.cc b/bochs/cpu/fetchdecode.cc index 80e2ff216..364e9d11e 100644 --- a/bochs/cpu/fetchdecode.cc +++ b/bochs/cpu/fetchdecode.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: fetchdecode.cc,v 1.189 2008-05-02 22:47:07 sshwarts Exp $ +// $Id: fetchdecode.cc,v 1.190 2008-06-09 19:35:59 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -2487,6 +2487,14 @@ fetch_b1: ilen++; switch (b1) { + case 0x0f: // 2-byte escape + i->setOpcodeExtension(); + if (ilen < remain) { + ilen++; + b1 = 0x100 | *iptr++; + break; + } + return(0); case 0x66: // OpSize BX_INSTR_PREFIX(BX_CPU_ID, b1); os_32 = !is_32; @@ -2569,14 +2577,6 @@ fetch_b1: goto fetch_b1; } return(0); - case 0x0f: // 2-byte escape - i->setOpcodeExtension(); - if (ilen < remain) { - ilen++; - b1 = 0x100 | *iptr++; - break; - } - return(0); default: break; } @@ -2956,16 +2956,15 @@ modrm_done: ia_opcode = Bx3DNowOpcodeInfo[i->modRMForm.Ib].IA; #endif - i->execute = BxOpcodesTable[ia_opcode]; - if (BX_NULL_SEG_REG(i->seg())) i->setSeg(BX_SEG_REG_DS); #if BX_SUPPORT_TRACE_CACHE - if ((attr & BxTraceEnd) || - (i->execute == &BX_CPU_C::BxError)) i->setStopTraceAttr(); + if ((attr & BxTraceEnd) || ia_opcode == BX_IA_ERROR) + i->setStopTraceAttr(); #endif + i->execute = BxOpcodesTable[ia_opcode]; i->setB1(b1); i->setILen(ilen); diff --git a/bochs/cpu/fetchdecode64.cc b/bochs/cpu/fetchdecode64.cc index 4c11ce3af..eafbd57be 100644 --- a/bochs/cpu/fetchdecode64.cc +++ b/bochs/cpu/fetchdecode64.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: fetchdecode64.cc,v 1.198 2008-05-08 21:34:22 sshwarts Exp $ +// $Id: fetchdecode64.cc,v 1.199 2008-06-09 19:35:59 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -3376,26 +3376,6 @@ fetch_b1: ilen++; switch (b1) { - case 0x66: // OpSize - BX_INSTR_PREFIX(BX_CPU_ID, b1); - rex_prefix = 0; - if(!sse_prefix) sse_prefix = SSE_PREFIX_66; - if (!i->os64L()) { - i->setOs32B(0); - offset = 0; - } - if (ilen < remain) { - goto fetch_b1; - } - return(0); - case 0x67: // AddrSize - BX_INSTR_PREFIX(BX_CPU_ID, b1); - rex_prefix = 0; - i->setAs64B(0); - if (ilen < remain) { - goto fetch_b1; - } - return(0); case 0x40: case 0x41: case 0x42: @@ -3418,6 +3398,14 @@ fetch_b1: goto fetch_b1; } return(0); + case 0x0f: // 2 byte escape + i->setOpcodeExtension(); + if (ilen < remain) { + ilen++; + b1 = 0x100 | *iptr++; + break; + } + return(0); case 0xf2: // REPNE/REPNZ BX_INSTR_PREFIX(BX_CPU_ID, b1); rex_prefix = 0; @@ -3436,6 +3424,24 @@ fetch_b1: goto fetch_b1; } return(0); + case 0x66: // OpSize + BX_INSTR_PREFIX(BX_CPU_ID, b1); + rex_prefix = 0; + if(!sse_prefix) sse_prefix = SSE_PREFIX_66; + i->setOs32B(0); + offset = 0; + if (ilen < remain) { + goto fetch_b1; + } + return(0); + case 0x67: // AddrSize + BX_INSTR_PREFIX(BX_CPU_ID, b1); + rex_prefix = 0; + i->setAs64B(0); + if (ilen < remain) { + goto fetch_b1; + } + return(0); case 0x2e: // CS: case 0x26: // ES: case 0x36: // SS: @@ -3471,14 +3477,6 @@ fetch_b1: goto fetch_b1; } return(0); - case 0x0f: // 2 byte escape - i->setOpcodeExtension(); - if (ilen < remain) { - ilen++; - b1 = 0x100 | *iptr++; - break; - } - return(0); default: break; } @@ -3864,16 +3862,15 @@ modrm_done: ia_opcode = Bx3DNowOpcodeInfo[i->modRMForm.Ib].IA; #endif - i->execute = BxOpcodesTable[ia_opcode]; - if (BX_NULL_SEG_REG(i->seg())) i->setSeg(BX_SEG_REG_DS); #if BX_SUPPORT_TRACE_CACHE - if ((attr & BxTraceEnd) || - (i->execute == &BX_CPU_C::BxError)) i->setStopTraceAttr(); + if ((attr & BxTraceEnd) || ia_opcode == BX_IA_ERROR) + i->setStopTraceAttr(); #endif + i->execute = BxOpcodesTable[ia_opcode]; i->setB1(b1); i->setILen(ilen);