From fe4b13e304decc48af0918fce281ed588f867a72 Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 27 Jun 2013 22:28:53 -0400 Subject: [PATCH] gbz80disasm: use existing labels as addresses --- extras/gbz80disasm.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extras/gbz80disasm.py b/extras/gbz80disasm.py index ed546ef98..c1b306cc6 100644 --- a/extras/gbz80disasm.py +++ b/extras/gbz80disasm.py @@ -587,6 +587,12 @@ def find_label(local_address, bank_id=0): return constants[local_address] return None +def find_address_from_label(label): + for label_entry in all_labels: + if label == label_entry["label"]: + return label_entry["address"] + return None + def asm_label(address): # why using a random value when you can use the address? return '.asm_%x' % address @@ -898,10 +904,15 @@ def all_outstanding_labels_are_reverse(byte_labels, offset): if __name__ == "__main__": + load_labels() addr = sys.argv[1] if ":" in addr: addr = addr.split(":") addr = int(addr[0], 16)*0x4000+(int(addr[1], 16)%0x4000) else: - addr = int(addr, 16) + label_addr = find_address_from_label(addr) + if label_addr: + addr = label_addr + else: + addr = int(addr, 16) print output_bank_opcodes(addr)[0]