Implemented mod, halt, and jump instructions
This commit is contained in:
parent
589657e31b
commit
4067027588
18
creature.go
18
creature.go
@ -91,8 +91,26 @@ func (machine *Machine) Execute (offset int) {
|
||||
machine.Push(notEqual)
|
||||
|
||||
case 0xc:
|
||||
// MOD
|
||||
// performs a modulo operation of the second to last
|
||||
// word on the stack to the last word on the stack
|
||||
machine.Push(machine.Pop() % machine.Pop())
|
||||
|
||||
case 0xd:
|
||||
// HALT
|
||||
// stops execution
|
||||
return
|
||||
|
||||
case 0xe:
|
||||
// JMP
|
||||
// jump to the address specified by the last word on the
|
||||
// stack if the second to last word on the stack is
|
||||
// nonzero
|
||||
jumpTo := machine.Pop()
|
||||
if machine.Pop() != 0 {
|
||||
machine.counter = jumpTo - 1
|
||||
}
|
||||
|
||||
case 0xf:
|
||||
}
|
||||
machine.counter ++
|
||||
|
Loading…
Reference in New Issue
Block a user