enable labels in gbz80disasm

fixes #102
This commit is contained in:
Bryan Bishop 2013-02-03 15:10:14 -06:00
parent c788666138
commit 82b8b5121a

View File

@ -568,8 +568,6 @@ def load_labels(filename="labels.json"):
crystal.scan_for_predefined_labels() crystal.scan_for_predefined_labels()
def find_label(local_address, bank_id=0): def find_label(local_address, bank_id=0):
return None
global all_labels global all_labels
# keep an integer # keep an integer
@ -577,17 +575,19 @@ def find_label(local_address, bank_id=0):
local_address1 = int(local_address.replace("$", "0x"), 16) local_address1 = int(local_address.replace("$", "0x"), 16)
else: local_address1 = local_address else: local_address1 = local_address
# turn local_address into a string # turn local_address into an integer
if type(local_address) == str: if type(local_address) == str:
if "0x" in local_address: local_address = local_address.replace("0x", "$") if "0x" in local_address:
elif not "$" in local_address: local_address = "$" + local_address local_address = local_address.replace("0x", "$")
if type(local_address) == int: elif "$" in local_address:
local_address = "$%.x" % (local_address) local_address = local_address.replace("$", "")
local_address = local_address.upper()
if type(local_address) == str:
local_address = int(local_address, 16)
for label_entry in all_labels: for label_entry in all_labels:
if label_entry["local_pointer"].upper() == local_address: if label_entry["address"] == local_address:
if label_entry["bank_id"] == bank_id or (local_address1 < 0x8000 and (label_entry["bank_id"] == 0 or label_entry["bank_id"] == 1)): if label_entry["bank"] == bank_id or (local_address1 < 0x8000 and (label_entry["bank"] == 0 or label_entry["bank"] == 1)):
return label_entry["label"] return label_entry["label"]
return None return None