Merge remote-tracking branch 'origin/master'

# Conflicts:
#	hal/instructions.go
master
Jonas Franz 5 years ago
commit 059c84e30a
Signed by: JonasFranzDEV
GPG Key ID: 7293A220B7C38080
  1. 20
      hal/instructions.go

@ -48,7 +48,8 @@ var instructions = []*Instruction{
InstructionJumpPos,
InstructionJumpNull,
InstructionJump,
InstructionAddnum,
InstructionAdd,
InstructionAddNum,
}
var InstructionStart = &Instruction{
@ -156,9 +157,22 @@ var InstructionJump = newJumpInstruction("JUMP", func(accumulator float64) bool
return true
})
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