Skip to content

Commit 4571996

Browse files
authored
Merge pull request #36 from cormacj/bugfixing
bump to v0.90. Fix defining words. Bugfix byte processing
2 parents b5ceaf8 + b04bec3 commit 4571996

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
2025-03-21: Bump to v0.80 - Add support for external labels, such as BIOS calls. Improved code detection methods.
44
2025-06-13: Bump to v0.85 - Add the ability to define user-defined labels to the labels file. Increased error handling, more informational messages.
55
2025-06-18: Bump to v0.87 - Corrected issues with string detection where strings weren't being properly decoded.
6-
2025-06-20: Bump to v0.89 - Bugfix for dropped `JP (IY)` instructions. Made JR decoding match the style of other jumps.
6+
2025-06-20: Bump to v0.89 - Bugfix for dropped `JP (IY)` instructions.
7+
Made JR decoding match the style of other jumps.
8+
Added template support for defining words

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,12 @@ A template file is a standard text file. The format for the file is as follows:
236236
`start address, end address, data type, label`
237237

238238
data types can be one of these:<br>
239-
b = byte *<br>
239+
b = byte <br>
240240
w = word<br>
241241
s = string<br>
242242
c = code<br>
243243
p = pointer<br>
244244

245-
* = still to be implimented
246-
247245
You can refer to a pointer by enclosing the address in (). When the disassembler sees this, it looks at the word at the pointer location and uses that value instead.
248246

249247
For example, in Amstrad ROMs 0xc004 is a pointer to the command names table. If a ROM has a value of `0xc123` at location `0xc004`, a template line should look like this:

z80-disassembler.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Pointer(NamedTuple):
9090
str_sizes = {}
9191
style = "asm"
9292
hexstyle = "0x"
93-
myversion = "0.89"
93+
myversion = "0.90"
9494

9595

9696
#--- Debugging functions ---
@@ -434,16 +434,16 @@ def process_template(filename):
434434
# print(loop)
435435
# mark_handled(addr,1,"D")
436436
case "b":
437-
mark_handled(addr,2,"Db")
437+
mark_handled(addr,1,"Db")
438438
case "w":
439-
mark_handled(addr,2,"Dw")
439+
mark_handled(addr,1,"Dw")
440440
case "c":
441441
# print("Code:",hex(begin),hex(end))
442442
for loop in range(begin,end):
443443
mark_handled(loop,1,"C")
444444
mark_handled(addr,3,"C")
445445
case "p":
446-
mark_handled(addr,2,"Dw")
446+
mark_handled(addr,2,"Dp")
447447
code_loc=begin #Get the address where the pointer is pointing to
448448
# mark_handled(code_loc,2,"Dw")
449449
case "s":
@@ -779,6 +779,8 @@ def type_lookup(datatype):
779779
return "data"
780780
case "Dw":
781781
return "data"
782+
case "Dp":
783+
return "data"
782784
case "C":
783785
return "code"
784786

@@ -1269,7 +1271,7 @@ def findstring(memstart, memend):
12691271
)
12701272
)
12711273
program_counter += 1
1272-
elif identified(program_counter) == "Dw":
1274+
elif identified(program_counter) == "Dp":
12731275
if is_in_code(program_counter):
12741276
tmp = get_from_code(program_counter,0) #code[loc][0]
12751277
out_tmp = (
@@ -1608,14 +1610,40 @@ def findstring(memstart, memend):
16081610
# debug("PC Bump")
16091611
program_counter += 1 #FIXME - tripping PC too much?
16101612
elif identified(program_counter) == "Dw":
1613+
if is_in_code(program_counter):
1614+
tmpl = get_from_code(program_counter,0) #Low byte
1615+
tmph = get_from_code(program_counter+1,0) # High byte
1616+
tmp = (tmph*0x100)+tmpl #make it a word
1617+
out_tmp=""
1618+
# print(f'\n\n{hex(tmp)}\n')
1619+
# out_tmp = (
1620+
# f'"{chr(tmpl)}"'
1621+
# if 31 < tmpl < 127
1622+
# else (
1623+
# f"('{chr(tmpl - 0x80)}') + {hexstyle}80" if 31 < (tmpl - 0x80) < 127 else hex(tmpl)
1624+
# )
1625+
# )
1626+
# out_tmp = out_tmp+" "+(
1627+
# f'"{chr(tmph)}"'
1628+
# if 31 < tmph < 127
1629+
# else (
1630+
# f"('{chr(tmph - 0x80)}') + {hexstyle}80" if 31 < (tmph - 0x80) < 127 else hex(tmph)
1631+
# )
1632+
# )
1633+
if commentlevel==0:
1634+
out_tmp="; "+out_tmp
1635+
1636+
code_output(program_counter, f"DEFB {hexstyle}{tmp:x}", list_address, f'{out_tmp}')
1637+
program_counter += 2
1638+
elif identified(program_counter) == "Dp":
16111639
# dump_code_array("---->",program_counter)
16121640

16131641
# debug("D2 - 2")
16141642
if is_in_code(program_counter):
16151643
# debug("D - 3")
16161644
tmpl = get_from_code(program_counter,0) #Low byte
16171645
tmph = get_from_code(program_counter+1,0) #High byte
1618-
tmp=((tmph*256)+tmpl) #make it a word
1646+
tmp=((tmph*0x100)+tmpl) #make it a word
16191647
if (tmp in labels) or (tmp in template_labels):
16201648
if (tmp in template_labels):
16211649
labelname=template_labels[tmp]
@@ -1657,7 +1685,6 @@ def findstring(memstart, memend):
16571685
# debug("C - 1a")
16581686
# debug("Processing relative jump")
16591687
jump_addr = handle_jump(b, program_counter)
1660-
# print(hex(jump_addr),lookup_label(jump_addr))
16611688
djnz_addr=lookup_label(jump_addr)
16621689
this_opcode = b.op.name
16631690
if len(z80.disasm(b).split(",")) > 1: # conditional jumps and calls
@@ -1675,6 +1702,9 @@ def findstring(memstart, memend):
16751702
# where $ is the current location, so this code adds the operator
16761703
# if its positive
16771704
tmp=f"{this_opcode} ${oper}{handle_jump(b,program_counter,True)} "
1705+
# if program_counter>0xc840 and program_counter<0xc862:
1706+
# print(f'{hex(program_counter)}: {hex(jump_addr)} -> {lookup_label(jump_addr)}, opcode={z80.disasm(b)} --> {tmp} {handle_jump(b,program_counter,True)} {hex(handle_jump(b,program_counter))} lookup: {lookup_label(jump_addr)} or {lookup_label(handle_jump(b,program_counter))}')
1707+
16781708
else:
16791709
if "," in this_opcode: # Fixup for JR nz, ADDR so this removes the space if it's a conditional JR
16801710
tmp = f"{this_opcode}" + lookup_label(jump_addr)

0 commit comments

Comments
 (0)