|
|
|
@ -135,9 +135,22 @@ var InstructionJumpNeg = &Instruction{ |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var InstructionAddnum = &Instruction{ |
|
|
|
|
var InstructionAdd = &Instruction{ |
|
|
|
|
Name: "ADD", |
|
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
|
index := int64(operand) |
|
|
|
|
if _, ok := module.programStorage[index]; !ok { |
|
|
|
|
return fmt.Errorf("index %d does not exist in program storage", index) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var InstructionAddNum = &Instruction{ |
|
|
|
|
Name: "ADDNUM", |
|
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) { |
|
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
|
module.accumulator = module.accumulator + operand |
|
|
|
|
return nil |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|