diff --git a/creature.go b/creature.go index 9f54810..befc13e 100644 --- a/creature.go +++ b/creature.go @@ -60,12 +60,36 @@ func (machine *Machine) Execute (offset int) { machine.Push(machine.Pop() / machine.Pop()) case 0x8: - // EQU + // EQ // checks if the last two words on the stack are equal + equal := 0 + if machine.Pop() == machine.Pop() { equal = 1 } + machine.Push(equal) case 0x9: + // GT + // checks if the last word on the stack is greater than + // the second to last word on the stack + greater := 0 + if machine.Pop() > machine.Pop() { greater = 1 } + machine.Push(greater) + case 0xa: + // LT + // checks if the last word on the stack is less than the + // second to last word on the stack + less := 0 + if machine.Pop() > machine.Pop() { less = 1 } + machine.Push(less) + case 0xb: + // NEQ + // checks if the last two words on the stack are not + // equal + notEqual := 0 + if machine.Pop() != machine.Pop() { notEqual = 1 } + machine.Push(notEqual) + case 0xc: case 0xd: case 0xe: