From a1ea9f30dab20d3919c3a2ed884d99c27246bb03 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 28 Aug 2022 16:59:11 -0400 Subject: [PATCH] Changed order of divide and subtract --- creature.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/creature.go b/creature.go index d49caa3..9f54810 100644 --- a/creature.go +++ b/creature.go @@ -44,10 +44,9 @@ func (machine *Machine) Execute (offset int) { case 0x5: // SUB - // subtracts the last two words on the stack - right := machine.Pop() - left := machine.Pop() - machine.Push(left - right) + // subtracts the second to last word on the stack from + // the last word on the stack + machine.Push(machine.Pop() - machine.Pop()) case 0x6: // MUL @@ -56,12 +55,14 @@ func (machine *Machine) Execute (offset int) { case 0x7: // DIV - // divides the last two words on the stack - right := machine.Pop() - left := machine.Pop() - machine.Push(left / right) + // divides the last word on the stack by the second to + // last word on the stack + machine.Push(machine.Pop() / machine.Pop()) case 0x8: + // EQU + // checks if the last two words on the stack are equal + case 0x9: case 0xa: case 0xb: