Z80 Disassembler [new] -

Pseudo-structure in C:

def recursive_disassemble(start, memory, visited): pc = start while pc < len(memory) and pc not in visited: visited.add(pc) insn, length = decode_one(pc, memory) print(f"pc:04X: insn") # simplistic flow analysis if "JP" in insn and "$" in insn: target = int(insn.split("$")[1], 16) if target not in visited: recursive_disassemble(target, memory, visited) break # unconditional jump elif "RET" in insn or "RETI" in insn or "RETN" in insn: break else: pc += length z80 disassembler

def decode_one(pc, memory): op = memory[pc] if op in opcode_map: mnemonic, length = opcode_map[op] if length == 3: operand = memory[pc+1] | (memory[pc+2] << 8) return (mnemonic % operand, length) return (mnemonic, length) else: return (".db $%02X" % op, 1) Pseudo-structure in C: def recursive_disassemble(start