Debug migliore nell'assembler
This commit is contained in:
parent
ec1576e017
commit
9d1cadf7d4
@ -45,7 +45,6 @@ def to_uint8(data):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def to_uint16(data):
|
def to_uint16(data):
|
||||||
print(data)
|
|
||||||
alphanum = re.compile("^[0-9]+$")
|
alphanum = re.compile("^[0-9]+$")
|
||||||
if isinstance(data, int):
|
if isinstance(data, int):
|
||||||
return struct.pack("<h", data)
|
return struct.pack("<h", data)
|
||||||
@ -65,7 +64,7 @@ def is_reg(data):
|
|||||||
|
|
||||||
def assemble_code(line):
|
def assemble_code(line):
|
||||||
global assembled
|
global assembled
|
||||||
sys.stdout.write("CODE:")
|
sys.stdout.write("CODE: ")
|
||||||
instruction = [x for x in re.split('\W', line) if x]
|
instruction = [x for x in re.split('\W', line) if x]
|
||||||
op_name = instruction[0]
|
op_name = instruction[0]
|
||||||
|
|
||||||
@ -73,13 +72,13 @@ def assemble_code(line):
|
|||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"ERROR WHILE ASSEMBLING UNKNOWN OPERATION: {}\n".format(op_name))
|
"ERROR WHILE ASSEMBLING UNKNOWN OPERATION: {}\n".format(op_name))
|
||||||
return False
|
return False
|
||||||
|
sys.stdout.write("{} {}\n".format(op_name, ", ".join(instruction[1::])))
|
||||||
if op_name == "MOVI":
|
if op_name == "MOVI":
|
||||||
op = ops[op_name]
|
op = ops[op_name]
|
||||||
dst = instruction[1]
|
dst = instruction[1]
|
||||||
if (is_reg(dst)):
|
if (is_reg(dst)):
|
||||||
dst = to_uint8(regs[dst])
|
dst = to_uint8(regs[dst])
|
||||||
src = to_uint16(instruction[2])
|
src = to_uint16(instruction[2])
|
||||||
print("SRC: {} | DST: {}".format(src, dst))
|
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"ERROR WHILE ASSEMBLING UNKNOWN REGISTER: {}\n".format(dst))
|
"ERROR WHILE ASSEMBLING UNKNOWN REGISTER: {}\n".format(dst))
|
||||||
|
Loading…
Reference in New Issue
Block a user