Fix handling of indirect references

This commit is contained in:
Maurizio Porrato 2020-01-23 21:58:48 +00:00
parent 706ae9238d
commit 67904719be
1 changed files with 9 additions and 4 deletions

13
asm.py
View File

@ -46,7 +46,7 @@ class ASM(SimpleNamespace):
return (0x1f, arg)
elif type(arg) == Indirect:
if type(arg.disp) == Expr:
disp = arg.disp.value
disp = getattr(arg.disp, "value", 0)
else:
disp = arg.disp
if arg.reg is None:
@ -67,10 +67,15 @@ class ASM(SimpleNamespace):
elif arg.reg in ('PC', 'EX'):
raise SyntaxError()
else:
if arg.disp == 0:
return (0x08+REGISTERS[arg.reg], None)
if hasattr(type(arg.reg), "getstr"):
r = arg.reg.getstr()
else:
return (0x10+REGISTERS[arg.reg], disp)
r = arg.reg
print("REG: "+r)
if arg.disp == 0:
return (0x08+REGISTERS[r], None)
else:
return (0x10+REGISTERS[r], disp)
def code(self):
o, b = OPCODES[self.op]
a_bits, a_extra = self.addr(self.a, True)