From 40cb893344279f8ba410aef335f9f034a082df9d Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 20 Jun 2020 14:51:17 +0200 Subject: [PATCH] Add LOADIND and STOREIND --- hal/instructions.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hal/instructions.go b/hal/instructions.go index a2d979a..4504988 100644 --- a/hal/instructions.go +++ b/hal/instructions.go @@ -56,6 +56,8 @@ var instructions = []*Instruction{ InstructionSub, InstructionMul, InstructionDiv, + InstructionLoadInd, + InstructionStoreInd, } var InstructionStart = &Instruction{ @@ -218,3 +220,19 @@ var InstructionSub = newMathInstruction("SUB", subInstr) var InstructionMul = newMathInstruction("MUL", mulInstr) var InstructionDiv = newMathInstruction("DIV", divInstr) + +var InstructionLoadInd = &Instruction{ + Name: "LOADIND", + ExecuteWithOperand: func(module *Module, operand float64) error { + module.mmu.Read(Address(operand)) + return nil + }, +} + +var InstructionStoreInd = &Instruction{ + Name: "STOREIND", + ExecuteWithOperand: func(module *Module, operand float64) error { + module.mmu.Write(Address(operand), module.accumulator) + return nil + }, +}