summaryrefslogtreecommitdiff
path: root/gbz80disasm.py
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-05-14 21:21:26 -0400
committeryenatch <yenatch@gmail.com>2013-05-15 14:39:19 -0400
commit66b9c8877d2d60228c463fc5cccbc16a9b799e52 (patch)
tree5c21a9561e2cdecf1f97f1e063f9c9c77a56a3ce /gbz80disasm.py
parenteef1b7af74784333f8e8a31706fb2f22fa1fdb3d (diff)
gbz80disasm: clean up $ff00+x handling
original-commit-id: 82d723840b14fc6b55c00f107a453bc0b0d80772
Diffstat (limited to 'gbz80disasm.py')
-rw-r--r--gbz80disasm.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/gbz80disasm.py b/gbz80disasm.py
index 2e800bb..dd69be2 100644
--- a/gbz80disasm.py
+++ b/gbz80disasm.py
@@ -723,19 +723,20 @@ def output_bank_opcodes(original_offset, max_byte_count=0x4000, include_last_add
opstr = opstr[:opstr.find("x")].lower() + insertion + opstr[opstr.find("x")+1:].lower()
# because the $ff00+$ff syntax is silly
- if opstr.count("$") > 0 and "+" in opstr:
- first_orig = opstr.split("$")[1].split("+")[0]
- first_num = "0x"+first_orig
- first_val = int(first_num, 16)
- second_orig = opstr.split("+$")[1].split("]")[0]
- second_num = "0x"+second_orig
- second_val = int(second_num, 16)
- combined_val = "$" + hex(first_val + second_val)[2:]
+ if opstr.count("$") > 1 and "+" in opstr:
+ first_orig = opstr[opstr.find("$"):opstr.find("+")]
+ first_val = eval(first_orig.replace("$","0x"))
+
+ second_orig = opstr[opstr.find("+$")+1:opstr.find("]")]
+ second_val = eval(second_orig.replace("$","0x"))
+
+ combined_val = "$%.4x" % (first_val + second_val)
result = find_label(combined_val, bank_id)
if result != None:
combined_val = result
- replacetron = "[$"+first_orig+"+$"+second_orig+"]"
- opstr = opstr.replace(replacetron, "["+combined_val+"]")
+
+ replacetron = "[%s+%s]" % (first_orig, second_orig)
+ opstr = opstr.replace(replacetron, "[%s]" % combined_val)
output += spacing + opstr
if include_comment: