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
1 changed files with 9 additions and 8 deletions

View File

@ -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: