From d0cb1b0013b005301ddbe7e3ae78cb80c294505a Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Mon, 22 Jun 2020 18:35:17 +0200 Subject: [PATCH] Fix instructions --- hal/instructions.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hal/instructions.go b/hal/instructions.go index f2ef066..287d3f7 100644 --- a/hal/instructions.go +++ b/hal/instructions.go @@ -214,7 +214,8 @@ var InstructionDiv = newMathInstruction("DIV", divInstr) var InstructionLoadInd = &Instruction{ Name: "LOADIND", ExecuteWithOperand: func(module *Module, operand float64) error { - module.mmu.Read(Address(module.register[int(operand)])) + targetAddr := module.mmu.Read(Address(operand)) + module.mmu.Read(Address(targetAddr)) return nil }, } @@ -222,7 +223,8 @@ var InstructionLoadInd = &Instruction{ var InstructionStoreInd = &Instruction{ Name: "STOREIND", ExecuteWithOperand: func(module *Module, operand float64) error { - module.mmu.Write(Address(module.register[int(operand)]), module.accumulator) + targetAddr := module.mmu.Read(Address(operand)) + module.mmu.Write(Address(targetAddr), module.accumulator) return nil }, }