master
kolaente 5 years ago
parent 059c84e30a
commit 574c217c0d
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 6
      hal/instructions.go

@ -160,11 +160,13 @@ var InstructionJump = newJumpInstruction("JUMP", func(accumulator float64) bool
var InstructionAdd = &Instruction{
Name: "ADD",
ExecuteWithOperand: func(module *Module, operand float64) error {
index := int64(operand)
if _, ok := module.programStorage[index]; !ok {
index := int(operand)
if len(module.register) <= index {
return fmt.Errorf("index %d does not exist in program storage", index)
}
module.accumulator += module.register[index]
return nil
},
}

Loading…
Cancel
Save