Additional compare status flags added. Five new compare ops.
Added checks in compareVal to set status-keys l and e to signify respectively 'lower than' and 'equal to'. Added the following control flow operations: * jl (less than) * je (equal to) * jge (greater than or equal to) * jle (less than or equal to) * jne (not equal to)
This commit is contained in:
parent
658d045846
commit
42b2ddbd0a
20
infernal.py
20
infernal.py
|
@ -123,8 +123,9 @@ class Emulator:
|
|||
def compareVal (self, valT1, valT2):
|
||||
val1 = self.getVal(valT2)
|
||||
val2 = self.getVal(valT1)
|
||||
self.status = {"g":val1>val2}
|
||||
|
||||
self.status["g"] = val1>val2
|
||||
self.status["l"] = val1<val2
|
||||
self.status["e"] = val1==val2
|
||||
def changedRegisters (self, *args):
|
||||
for reg, val in args:
|
||||
self.changes[reg] = val
|
||||
|
@ -193,6 +194,21 @@ class Emulator:
|
|||
elif opcode == "jg":
|
||||
if self.status["g"]:
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "jl":
|
||||
if self.status["l"]:
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "je":
|
||||
if self.status["e"]:
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "jge":
|
||||
if (self.status["g"] or self.status["e"]):
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "jle":
|
||||
if (self.status["l"] or self.status["e"]):
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "jne":
|
||||
if not self.status["e"]:
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
elif opcode == "jmp":
|
||||
self.registers['%rip'] = self.labels[instruct[1]]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user