diff --git a/creature.go b/creature.go index befc13e..a2c3ec0 100644 --- a/creature.go +++ b/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 ++