Implemented comparison instructions
This commit is contained in:
parent
a1ea9f30da
commit
589657e31b
26
creature.go
26
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:
|
||||
|
Loading…
Reference in New Issue
Block a user