Debug migliore nell'assembler

This commit is contained in:
Giulio De Pasquale 2017-05-15 12:56:05 +02:00
parent ec1576e017
commit 9d1cadf7d4

View File

@ -45,7 +45,6 @@ def to_uint8(data):
return None
def to_uint16(data):
print(data)
alphanum = re.compile("^[0-9]+$")
if isinstance(data, int):
return struct.pack("<h", data)
@ -73,13 +72,13 @@ def assemble_code(line):
sys.stderr.write(
"ERROR WHILE ASSEMBLING UNKNOWN OPERATION: {}\n".format(op_name))
return False
sys.stdout.write("{} {}\n".format(op_name, ", ".join(instruction[1::])))
if op_name == "MOVI":
op = ops[op_name]
dst = instruction[1]
if (is_reg(dst)):
dst = to_uint8(regs[dst])
src = to_uint16(instruction[2])
print("SRC: {} | DST: {}".format(src, dst))
else:
sys.stderr.write(
"ERROR WHILE ASSEMBLING UNKNOWN REGISTER: {}\n".format(dst))