From 1a46a529ee7518556241d71ba584c829d64dc445 Mon Sep 17 00:00:00 2001 From: otabuzzman Date: Sun, 13 Apr 2025 21:10:22 +0200 Subject: [PATCH] Fix test suite --- .gitignore | 1 + devices/intel8086/branch.go | 7 +++---- devices/io/IOPortAccessController.go | 2 +- tests/mov_test.go | 4 ++-- tests/simple_cpu_test.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 1c2d52b..981ef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/* +*.exe \ No newline at end of file diff --git a/devices/intel8086/branch.go b/devices/intel8086/branch.go index a8f24de..09b2dcb 100644 --- a/devices/intel8086/branch.go +++ b/devices/intel8086/branch.go @@ -184,8 +184,8 @@ func INSTR_JMP_FAR_M16(core *CpuCore) { // core.registers.CS.Base = uint32(segment) << 4 core.flags.IsFarJump = true - core.logInstruction(fmt.Sprintf("[%#04x] JMP %s (dst=%#04x:%#04x)", - core.GetCurrentlyExecutingInstructionAddress(), addrName, addrName)) + core.logInstruction(fmt.Sprintf("[%#04x] JMP %s (JMP_FAR_M16)", + core.GetCurrentlyExecutingInstructionAddress(), addrName)) return } else if addrMode == ADR_TYPE_INDIRECT { // Read the offset (IP) and segment (CS) from memory @@ -230,10 +230,9 @@ func INSTR_JMP_NEAR_REL16(core *CpuCore) { } func INSTR_CALL_NEAR_REL16(core *CpuCore) { - // Get the current IP and read the offset currentIP := core.GetIP() - offset, err := core.readImm16() + offset, err := core.memoryAccessController.ReadMemoryValue16(uint32(core.GetCurrentCodePointer()) + 1) // Calculate the address after the instruction and the destination address nextIP := currentIP + 3 // Size of this CALL instruction diff --git a/devices/io/IOPortAccessController.go b/devices/io/IOPortAccessController.go index 12d1b3b..2fd47a3 100644 --- a/devices/io/IOPortAccessController.go +++ b/devices/io/IOPortAccessController.go @@ -277,7 +277,7 @@ func (r *IOPortAccessController) WriteAddr8(port_addr uint16, value uint8) { return } - log.Println("Unhandled IO port write: PORT=[%#04x], value=%#02x", port_addr, value) + log.Printf("Unhandled IO port write: PORT=[%#04x], value=%#02x\n", port_addr, value) } } diff --git a/tests/mov_test.go b/tests/mov_test.go index 8279c1b..3ae51ee 100644 --- a/tests/mov_test.go +++ b/tests/mov_test.go @@ -12,7 +12,7 @@ func Test_MovTests(t *testing.T) { testPc.GetMemoryController().UnlockBootVector() testPc.GetPrimaryCpu().SetCS(0x0) - testPc.GetPrimaryCpu().SetIP(1) + testPc.GetPrimaryCpu().SetIP(0) instructions := []uint8{0xb8, 0x00, 0x90, 0x8E, 0xD8} @@ -35,7 +35,7 @@ func Test_MovDecodeOperandSizeOverridePrefix(t *testing.T) { testPc.GetMemoryController().UnlockBootVector() testPc.GetPrimaryCpu().SetCS(0x0) - testPc.GetPrimaryCpu().SetIP(1) + testPc.GetPrimaryCpu().SetIP(0) instructions := []uint8{0x66, 0x25, 0xFF, 0xFF, 0xFF, 0x9F} diff --git a/tests/simple_cpu_test.go b/tests/simple_cpu_test.go index bb89b11..4328f93 100644 --- a/tests/simple_cpu_test.go +++ b/tests/simple_cpu_test.go @@ -13,7 +13,7 @@ func Test_DoCpuTest(t *testing.T) { testPc.GetMemoryController().UnlockBootVector() testPc.GetPrimaryCpu().SetCS(0x0) - testPc.GetPrimaryCpu().SetIP(1) + testPc.GetPrimaryCpu().SetIP(0) instructions := []uint8{0xf, 0x20, 0xc0, 0x66, 0x25, 0xff, 0xff, 0xff, 0x9f, 0xf, 0x22, 0xc0, 0xff, 0xe7, 0xf, 0x1, 0xe0}