From 705dcd2d0515a11d78df1f8c7bc7bec3376ab478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 20 Oct 2014 19:42:52 +0000 Subject: [PATCH] [FAST486] - Control register 0 is CR0: use FAST486_REG_CR0 instead of 0, as it is done in the rest of the code. - Improve a if/else if control. - Don't halt the processor in the middle of prefixes processing. svn path=/trunk/; revision=64851 --- reactos/lib/fast486/common.c | 4 ++-- reactos/lib/fast486/common.inl | 9 +-------- reactos/lib/fast486/debug.c | 2 +- reactos/lib/fast486/fast486.c | 2 +- reactos/lib/fast486/opcodes.c | 3 +-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/reactos/lib/fast486/common.c b/reactos/lib/fast486/common.c index 03378c2b3bd..1e9311ae00b 100644 --- a/reactos/lib/fast486/common.c +++ b/reactos/lib/fast486/common.c @@ -55,7 +55,7 @@ Fast486ReadMemory(PFAST486_STATE State, } /* Check for protected mode */ - if (State->ControlRegisters[0] & FAST486_CR0_PE) + if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) { /* Privilege checks */ @@ -122,7 +122,7 @@ Fast486WriteMemory(PFAST486_STATE State, } /* Check for protected mode */ - if (State->ControlRegisters[0] & FAST486_CR0_PE) + if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) { /* Privilege checks */ diff --git a/reactos/lib/fast486/common.inl b/reactos/lib/fast486/common.inl index 57bf933633a..4990172fb1a 100644 --- a/reactos/lib/fast486/common.inl +++ b/reactos/lib/fast486/common.inl @@ -762,7 +762,7 @@ Fast486ParseModRegRm(PFAST486_STATE State, ModRegRm->Register = (ModRmByte >> 3) & 0x07; /* Check the mode */ - if ((ModRmByte >> 6) == 3) + if (Mode == 3) { /* The second operand is also a register */ ModRegRm->Memory = FALSE; @@ -886,7 +886,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, /* [BX + SI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EBX].LowWord + State->GeneralRegs[FAST486_REG_ESI].LowWord; - break; } @@ -895,7 +894,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, /* [BX + DI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EBX].LowWord + State->GeneralRegs[FAST486_REG_EDI].LowWord; - break; } @@ -904,7 +902,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, /* SS:[BP + SI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EBP].LowWord + State->GeneralRegs[FAST486_REG_ESI].LowWord; - break; } @@ -913,7 +910,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, /* SS:[BP + DI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EBP].LowWord + State->GeneralRegs[FAST486_REG_EDI].LowWord; - break; } @@ -921,7 +917,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, { /* [SI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_ESI].LowWord; - break; } @@ -929,7 +924,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, { /* [DI] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EDI].LowWord; - break; } @@ -953,7 +947,6 @@ Fast486ParseModRegRm(PFAST486_STATE State, { /* [BX] */ ModRegRm->MemoryAddress = State->GeneralRegs[FAST486_REG_EBX].LowWord; - break; } } diff --git a/reactos/lib/fast486/debug.c b/reactos/lib/fast486/debug.c index 9af5b9620a2..974e99b3588 100644 --- a/reactos/lib/fast486/debug.c +++ b/reactos/lib/fast486/debug.c @@ -137,7 +137,7 @@ Fast486DumpState(PFAST486_STATE State) { DbgPrint("\nFast486DumpState -->\n"); DbgPrint("\nCPU currently executing in %s mode at %04X:%08X\n", - (State->ControlRegisters[0] & FAST486_CR0_PE) ? "protected" : "real", + (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) ? "protected" : "real", State->SegmentRegs[FAST486_REG_CS].Selector, State->InstPtr.Long); DbgPrint("\nGeneral purpose registers:\n" diff --git a/reactos/lib/fast486/fast486.c b/reactos/lib/fast486/fast486.c index 9df60e5c462..6bfd382017e 100644 --- a/reactos/lib/fast486/fast486.c +++ b/reactos/lib/fast486/fast486.c @@ -54,9 +54,9 @@ Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command) /* Main execution loop */ do { -NextInst: if (!State->Halted) { +NextInst: /* Check if this is a new instruction */ if (State->PrefixFlags == 0) State->SavedInstPtr = State->InstPtr; diff --git a/reactos/lib/fast486/opcodes.c b/reactos/lib/fast486/opcodes.c index cadbd540d57..06b3f9eea54 100644 --- a/reactos/lib/fast486/opcodes.c +++ b/reactos/lib/fast486/opcodes.c @@ -4985,8 +4985,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeLoop) /* Additional rule for LOOPNZ */ if (State->Flags.Zf) Condition = FALSE; } - - if (Opcode == 0xE1) + else if (Opcode == 0xE1) { /* Additional rule for LOOPZ */ if (!State->Flags.Zf) Condition = FALSE;