From 2a606aaaf8e5cc08bf3e89dd79efddf5c674209f Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 22 Jun 2020 16:55:21 +0200 Subject: [PATCH] Fix register handling --- hal/instructions.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hal/instructions.go b/hal/instructions.go index 71ad01e..58d7e20 100644 --- a/hal/instructions.go +++ b/hal/instructions.go @@ -109,7 +109,7 @@ var InstructionLoad = &Instruction{ if len(module.register) <= index { return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO)) } - module.accumulator = module.register[index] + module.accumulator = module.mmu.Read(Address(operand)) return nil }, } @@ -129,7 +129,7 @@ var InstructionStore = &Instruction{ if len(module.register) <= index { return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO)) } - module.register[index] = module.accumulator + module.mmu.Write(Address(operand), module.accumulator) return nil }, } @@ -209,7 +209,8 @@ func newMathInstruction(name string, operation func(accumulator, register float6 return fmt.Errorf("index %d does not exist in register", index) } - module.accumulator = operation(module.accumulator, module.register[index]) + param := module.mmu.Read(Address(index)) + module.accumulator = operation(module.accumulator, param) return nil }, }