def one_eprom(p, disass, start, eprom_size): if False: x = p.t.add(start, start + eprom_size, "eprom") x.blockcmt += "\n-\nEPROM at 0x%x-0x%x\n\n" % \ (start, start + eprom_size - 1) # Calculate checksum j = 0^p.m.w16(start) for jj in range(2, eprom_size): j += p.m.rd(start + jj) j &= 0xffff if j == 0xffff: j = "OK" else: print("NB: Bad Eprom checksum @%x" % start) j = "BAD" x = const.w16(p, start) x.cmt.append("EPROM checksum (%s)" % j) x.blockcmt += "-\nEPROM %04x\n" % start x = const.byte(p, start + 2) x.cmt.append("EPROM identifier") # Jump table at front of EPROM for ax in range(start + 3, start + eprom_size, 3): if p.m.rd(ax) != 0x7e: break disass(ax)
def one_eprom(p, disass, start, eprom_size): if False: x = p.t.add(start, start + eprom_size, "eprom") x.blockcmt += "\n-\nEPROM at 0x%x-0x%x\n\n" % \ (start, start + eprom_size - 1) # Calculate checksum j = 0 ^ p.m.w16(start) for jj in range(2, eprom_size): j += p.m.rd(start + jj) j &= 0xffff if j == 0xffff: j = "OK" else: print("NB: Bad Eprom checksum @%x" % start) j = "BAD" x = const.w16(p, start) x.cmt.append("EPROM checksum (%s)" % j) x.blockcmt += "-\nEPROM %04x\n" % start x = const.byte(p, start + 2) x.cmt.append("EPROM identifier") # Jump table at front of EPROM for ax in range(start + 3, start + eprom_size, 3): if p.m.rd(ax) != 0x7e: break disass(ax)
def eprom(p, disass, start, end, sz): lx = list() for ax in range(start, end, sz): lx.append(ax >> 8) lx.append(ax & 0xff) one_eprom(p, disass, ax, sz) lx.append(end >> 8) lx.append(end & 0xff) # Find the table of eprom locations l = p.m.find(start, end, lx) print("EPROM", l) assert len(l) == 1 x = p.t.add(l[0], l[0] + len(lx), "tbl") x.blockcmt += "-\nTable of EPROM locations" for ax in range(x.start, x.end, 2): const.w16(p, ax) p.setlabel(l[0], "EPROM_TBL")
def chargen(adr): const.byte(p,adr) const.byte(p,adr + 1) for j in range(2, 66, 2): x = const.w16(p, adr + j) y = p.m.b16(adr + j) s = "" for b in range(15, -1, -1): if y & (1 << b): s += "#" else: s += "." x.lcmt(s)
def chargen(adr): const.byte(p, adr) const.byte(p, adr + 1) for j in range(2, 66, 2): x = const.w16(p, adr + j) y = p.m.b16(adr + j) s = "" for b in range(15, -1, -1): if y & (1 << b): s += "#" else: s += "." x.lcmt(s)
def caseW(a): x = p.m.b32(a) assert (x >> 16) == 0x2100 l = x & 0xffff y = p.m.b16(a + 4) assert y == 0x1402 y = p.m.b32(a + 6) z = p.m.b16(y - 2) assert z == 0x1e28 z = cpu.disass(y - 2) print("CASE", "l=%d" % l, "y=%x" % y) q = dict() for i in range (0,l): const.w16(p, y + 2 * i) t = y + 2 * l + 4 * i idx = p.m.b16(y + 2 * i) res = p.m.b32(t) # XXX: should be .PTR x = const.w32(p, t) x.lcmt(" case %04x" % idx) z.flow("cond", "%d" % i, res) cpu.disass(res) q[idx]= res return q
def caseW(a): x = p.m.b32(a) assert (x >> 16) == 0x2100 l = x & 0xffff y = p.m.b16(a + 4) assert y == 0x1402 y = p.m.b32(a + 6) z = p.m.b16(y - 2) assert z == 0x1e28 z = cpu.disass(y - 2) print("CASE", "l=%d" % l, "y=%x" % y) q = dict() for i in range(0, l): const.w16(p, y + 2 * i) t = y + 2 * l + 4 * i idx = p.m.b16(y + 2 * i) res = p.m.b32(t) # XXX: should be .PTR x = const.w32(p, t) x.lcmt(" case %04x" % idx) z.flow("cond", "%d" % i, res) cpu.disass(res) q[idx] = res return q
def lstr(p, a): const.w16(p, a) const.txtlen(p, a + 2, p.m.b16(a))
m.fromfile("u91.bin", 1, 2) m.fromfile("u94.bin", 0x2000, 2) m.fromfile("u92.bin", 0x2001, 2) m.bcols = 8 ####################################################################### # Create a pyreveng instance p = pyreveng.pyreveng(m) ####################################################################### # Instantiate a disassembler cpu = cpus.z8000.z8000(p) ####################################################################### # Provide hints for disassembly const.w16(p, 0) const.w16(p, 2) const.w16(p, 4) const.w16(p, 6) cpu.disass(p.m.b16(6)) ####################################################################### # More hints... if False: # Args to 0x050c and 0x12f0 def lstr(p, a): const.w16(p, a) const.txtlen(p, a + 2, p.m.b16(a))
m.add_seg(1, m1) ####################################################################### # Create a pyreveng instance p = pyreveng.pyreveng(m) print("%x" % p.lo, "%x" % p.hi) ####################################################################### # Instantiate a disassembler cpu = cpus.z8000.z8000(p, segmented = True) ####################################################################### # Provide hints for disassembly # const.w16(p, 0) x = const.w16(p, 2) x.lcmt("Reset PSW") x = const.w16(p, 4) x.lcmt("Reset SEG") x = const.w16(p, 6) x.lcmt("Reset PC") p.setlabel(p.m.b16(6), "RESET") cpu.disass(p.m.b16(6)) cpu.disass(0) ####################################################################### # non-stack calls LDA RR10,0x??:0x???? def rr10_call(adr): # Turn a jump into a call
for i in range(0xf0, 0x100): cpu.io_port[i] = "DMA_%02x" % i ####################################################################### cpu.disass(0) cpu.disass(0x0027) ####################################################################### # Interrupt vectors for i in range(0x7300,0x7320, 2): da = p.m.l16(i) cpu.disass(da) const.w16(p, i) ####################################################################### while p.run(): pass ####################################################################### cpu.to_tree() ####################################################################### p.setlabel(0x7000, "Error_No_System_Files") const.txtlen(p, 0x707d, 0x15) # p.setlabel(0x707d, '"**NO SYSTEM FILES**"')
m.fromfile("u91.bin", 1, 2) m.fromfile("u94.bin", 0x2000, 2) m.fromfile("u92.bin", 0x2001, 2) m.bcols=8 ####################################################################### # Create a pyreveng instance p = pyreveng.pyreveng(m) ####################################################################### # Instantiate a disassembler cpu = cpus.z8000.z8000(p) ####################################################################### # Provide hints for disassembly const.w16(p, 0) const.w16(p, 2) const.w16(p, 4) const.w16(p, 6) cpu.disass(p.m.b16(6)) ####################################################################### # More hints... if False: # Args to 0x050c and 0x12f0 def lstr(p, a): const.w16(p, a) const.txtlen(p, a + 2, p.m.b16(a))
m.add_seg(1, m1) ####################################################################### # Create a pyreveng instance p = pyreveng.pyreveng(m) print("%x" % p.lo, "%x" % p.hi) ####################################################################### # Instantiate a disassembler cpu = cpus.z8000.z8000(p, segmented=True) ####################################################################### # Provide hints for disassembly # const.w16(p, 0) x = const.w16(p, 2) x.lcmt("Reset PSW") x = const.w16(p, 4) x.lcmt("Reset SEG") x = const.w16(p, 6) x.lcmt("Reset PC") p.setlabel(p.m.b16(6), "RESET") cpu.disass(p.m.b16(6)) cpu.disass(0) ####################################################################### # non-stack calls LDA RR10,0x??:0x???? def rr10_call(adr):
x = const.w16(p, adr) x.lcmt(txt) cpu.disass(da) p.setlabel(da, txt) if True: #vector(0xfffa, "NMI") vector(0xfffc, "RESET") vector(0xfffe, "IRQ") for a in range(0xfff3, 0xfff9, 3): cpu.disass(a) pass if False: for a in range(0xff9a, 0xffa0, 2): const.w16(p, a) cpu.disass(p.m.l16(a)) for a in range(0xff93, 0xff9a, 3): const.w16(p, a + 1) cpu.disass(a) pass ####################################################################### if True: while p.run(): pass x = p.t.add(0xe28a, 0xe29d, "consts") x.blockcmt = """- Command byte dispatch table """
def vector(adr, txt): da = p.m.l16(adr) x = const.w16(p, adr) x.lcmt(txt) cpu.disass(da) p.setlabel(da, txt)
const.fill(p, hi=0x6bff) const.fill(p, hi=0x6fff) const.fill(p, hi=0x73ff) const.fill(p, hi=0x77ff) const.fill(p, hi=0x7bff) const.fill(p, hi=0x7eff) const.fill(p, hi=0x7ff7) #---------------------------------------------------------------------- # See 0x61a4 cpu.disass(0x6175) # See 0x61fa cpu.disass(0x616b) cpu.disass(0x60a1) const.w16(p, 0x68b7) #---------------------------------------------------------------------- while p.run(): pass #---------------------------------------------------------------------- hp53xx.nmi_debugger(p, cpu) #---------------------------------------------------------------------- hp5359_cmds = { "F": "Frequency Mode", "P": "Period Mode", "D": "Delay", "W": "Width", "SS": "Step Size", "SU": "Step Up", "SD": "Step Down",
const.fill(p, hi=0x6fff) const.fill(p, hi=0x73ff) const.fill(p, hi=0x77ff) const.fill(p, hi=0x7bff) const.fill(p, hi=0x7eff) const.fill(p, hi=0x7ff7) #---------------------------------------------------------------------- # See 0x61a4 cpu.disass(0x6175) # See 0x61fa cpu.disass(0x616b) cpu.disass(0x60a1) const.w16(p, 0x68b7) #---------------------------------------------------------------------- while p.run(): pass #---------------------------------------------------------------------- hp53xx.nmi_debugger(p, cpu) #---------------------------------------------------------------------- hp5359_cmds = { "F": "Frequency Mode", "P": "Period Mode", "D": "Delay", "W": "Width", "SS": "Step Size", "SU": "Step Up", "SD": "Step Down",