Changed order of divide and subtract

This commit is contained in:
Sasha Koshka 2022-08-28 16:59:11 -04:00
parent efc263fe72
commit a1ea9f30da

View File

@ -44,10 +44,9 @@ func (machine *Machine) Execute (offset int) {
case 0x5: case 0x5:
// SUB // SUB
// subtracts the last two words on the stack // subtracts the second to last word on the stack from
right := machine.Pop() // the last word on the stack
left := machine.Pop() machine.Push(machine.Pop() - machine.Pop())
machine.Push(left - right)
case 0x6: case 0x6:
// MUL // MUL
@ -56,12 +55,14 @@ func (machine *Machine) Execute (offset int) {
case 0x7: case 0x7:
// DIV // DIV
// divides the last two words on the stack // divides the last word on the stack by the second to
right := machine.Pop() // last word on the stack
left := machine.Pop() machine.Push(machine.Pop() / machine.Pop())
machine.Push(left / right)
case 0x8: case 0x8:
// EQU
// checks if the last two words on the stack are equal
case 0x9: case 0x9:
case 0xa: case 0xa:
case 0xb: case 0xb: