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