master
kolaente 5 years ago
parent e51c5be227
commit c3ca989262
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 17
      hal/instructions.go

@ -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
},
}

Loading…
Cancel
Save