Esempio n. 1
0
 def tbl(seg, off_lo, off_hi):
     pj.add(off_lo, off_hi, "%04x-jmp-tbl" % seg)
     for i in range(off_lo, off_hi, 2):
         off = pj.m.lu16(i)
         a = (seg << 4) + off
         x = data.Codeptr(pj, i, i + 2, a)
         pj.todo(a, cx.disass)
Esempio n. 2
0
 def tbl(seg, off_lo, off_hi):
     cx.m.add_range(off_lo, off_hi, txt="%04x-jmp-tbl" % seg)
     for i in range(off_lo, off_hi, 2):
         off = cx.m.lu16(i)
         a = (seg << 4) + off
         x = data.Codeptr(cx.m, i, i + 2, a)
         cx.disass(a)
Esempio n. 3
0
	def vectors(self, pj, hi=0x400):
		y = data.Const(pj, 0, 4, "0x%08x", pj.m.bu32, 4)
		y.lcmt = "Reset SP"
		vn = {}
		vi = {}
		a = 0x4
		while a < hi:
			x = pj.m.bu32(a)
			if x in (0x0, 0xffffffff):
				y = data.Const(pj, a, a + 4,
				    "0x%04x", pj.m.bu32, 4)
			else:
				if x not in vn:
					vi[x] = self.disass(pj, x)
					vn[x] = []
				vn[x].append(a >> 2)
				if x > a:
					y = data.Codeptr(pj, a, a + 4, x)
			y.lcmt = self.vector_name(a >> 2)
			hi = min(hi, x)
			a += 4
		mv = 0
		for i in vn:
			for v in vn[i]:
				k = self.vector_name(v)
				if vi[i] != None:
					vi[i].lcmt += "--> " + k + "\n"

			if len(vn[i]) == 1:
				k = self.vector_name(vn[i][0])
				pj.set_label(i, k)
			else:
				pj.set_label(i, "VECTORS_%d" % mv)
				mv += 1
Esempio n. 4
0
def example():
    m = mem.Stackup((FILENAME,), nextto=__file__)
    cx = mcs48.mcs48()
    cx.m.map(m, 0)

    cx.vectors()

    for a in range(0x0a, 0x21):
        t = cx.m[a]
        data.Codeptr(cx.m, a, a + 1, t)
        cx.disass(t)
        cx.m.set_block_comment(t, "From PTR 0x%x" % a)


    for a in range(0x000, 0x800, 0x100):
        cx.disass(a + 0xfe)

    data.Txt(cx.m, 0x5ae, 0x5dc, label=False)
    data.Txt(cx.m, 0x5dc, 0x5f4, label=False)

    for a in (
            0x695,
            0x700,
            0x70d,
            0x720,
    ):
        cx.disass(a)
        cx.m.set_block_comment(a, "Manual")
    return NAME, (cx.m,)
Esempio n. 5
0
		def __init__(self, pj, nm, i, j):
			self.nm = nm
			self.b = 0x195c4
			self.i = i
			self.j = j
			self.fi = pj.m.rd(self.b + i)
			self.args = []
			for a in range(j):
				self.args.append(pj.m.rd(self.b + i + 1 + a))
			super(params, self).__init__(pj, self.b + i, self.b + i + 1 + j)

			self.fp = 0x196b6 + self.fi * 4
			self.fa = pj.m.bu32(self.fp)
			pj.todo(self.fa, cpu.disass)
			data.Codeptr(pj, self.fp, self.fp + 4, self.fa)
			pj.set_label(self.fa, "F_" + nm + "(" + self.summ() + ")")
Esempio n. 6
0
 def codeptr(self, pj, adr):
     t = pj.m.bu16(adr)
     c = data.Codeptr(pj, adr, adr + 2, t)
     pj.todo(t, self.disass)
     return c
Esempio n. 7
0
def example():
    cx = mc6809.mc6809()
    cx.m.map(
        mem.Stackup((FILENAMES[0], ), nextto=__file__),
        0x0000,
    )
    cx.m.map(
        mem.Stackup((FILENAMES[1], ), nextto=__file__),
        0xe000,
    )

    s = 0
    for a in range(0x0000, 0x2000, 2):
        s += cx.m.bu16(a)
    print("SUM 0x0000-0x1fff = 0x%x" % s)

    s = 0
    for a in range(0xe000, 0x10000, 2):
        s += cx.m.bu16(a)
    print("SUM 0xe000-0xffff = 0x%x" % s)

    cx.add_ins(our_desc, our_ins)

    for a, b in SYMBOLS.items():
        cx.m.set_label(a, b)

    gpu = hp1345a.hp1345a()

    cx.vectors(which=("RST", "NMI", "SWI", "IRQ", "FIRQ", "SWI2"))

    if True:
        # screen texts
        a = 0xd95
        while a < 0xf4d:
            z = Scrtxt(cx.m, a)
            a = z.hi

        Scrtxt(cx.m, 0x01db)
        Scrtxt(cx.m, 0xea56)
        Scrtxt(cx.m, 0xea6a)
        Scrtxt(cx.m, 0xea7d)
        Scrtxt(cx.m, 0xee37)
        Scrtxt(cx.m, 0xee51)
        Scrtxt(cx.m, 0xfa6d)

    if True:
        n = 0
        c = {}
        while cx.m.bu16(0xfd0 + n):
            y = data.Txt(cx.m, 0xfd0 + n, 0xfd0 + n + 2, align=1)
            ta = 0x1062 + n
            t = cx.m.bu16(ta)
            z = data.Codeptr(cx.m, ta, ta + 2, t)
            z.lcmt += y.txt
            cx.disass(t)
            if t not in c:
                c[t] = []
            if y.txt not in CMDS:
                print("Undoc command", y.txt)
                CMDS[y.txt] = [t, "???"]
            else:
                CMDS[y.txt][0] = t
            c[t].append(y.txt)
            n += 2
        for i in c:
            c[i].sort()
            cx.m.set_label(i, "CMD_" + "_".join(c[i]))

        for i in CMDS:
            c = CMDS[i]
            if c[0] == 0:
                print(i, "CMD not implemented (" + c[1] + ")")
                continue
            if c[1][0] == "?":
                print(i, "CMD not documented (%s)" % c[1][1:])
            cx.m.set_block_comment(c[0], " COMMAND " + i + " - " + c[1])

    if True:
        for a in (0x129d, 0x17e3, 0x181e, 0xe0e3, 0xee7e):
            w = cx.m[a + 1] + 1
            t = cx.m.bu16(a + 4)
            for i in range(w):
                d = cx.m.bu16(t)
                data.Codeptr(cx.m, t, t + 2, d)
                cx.disass(d)
                t += 2

    if True:
        # Random strings
        ttab(cx.m, 0xf019, 0xf03b)
        ttab(cx.m, 0xf1d1, 0xf25c)
        ttab(cx.m, 0xf412, 0xf44c)
        ttab(cx.m, 0xefd7, 0xeff7)

    if True:
        a = 0xf56e
        while cx.m[a]:
            y = data.Txt(cx.m, a, a + 6, label=False, align=1)
            a = y.hi

    if True:
        for a in range(0xf811, 0xf825, 2):
            #d = cx.m.bu16(a)
            cx.codeptr(a)
            #cx.disass(d)

    if True:
        # HP1345 testpatterns
        cx.m.set_label(0xfbed, "IMG_PIKES_PEAK")
        cx.m.set_label(0xfd41, "IMG_FOCUS")
        for a0 in (0xfbed, 0xfd41):
            a = a0
            data.Const(cx.m, a, a + 2, func=cx.m.bu16, fmt="0x%x", size=2)
            l = cx.m.bu16(a)
            a += 2
            hp1345_render.svg(cx.m, a, a + l * 2)
            while l > 0:
                gpu.disass(a, cx.m)
                a += 2
                l -= 1

    if True:
        # No idea, possibly length error in IMG_FOCUS ?
        data.Const(cx.m, 0xff17, 0xff19, fmt="0x%04x", func=cx.m.bu16, size=2)

    if True:
        # Special character handling
        b = 0xf75b
        c = 0xf778
        cx.m.set_label(b, "CHR_TBL_KEY")
        cx.m.set_label(c, "CHR_TBL_PTR")
        data.Const(cx.m, b, c, fmt="0x%x")
        a = c
        while b < c:
            p = cx.m.bu16(a)
            y = data.Dataptr(cx.m, a, a + 2, p)
            cx.m.set_label(p, "CHR_TBL_%02x" % cx.m[b])
            while True:
                z = data.Const(cx.m,
                               p,
                               p + 2,
                               func=cx.m.bu16,
                               fmt="0x%x",
                               size=2)
                if cx.m[p + 1] & 0x80:
                    break
                p += 2
            b += 1
            a += 2

    # Stuff not accessed from anywhere

    cx.disass(0xe5a1)
    cx.m.set_block_comment(0xe5a1, "Unused ROM checksum code")
    cx.m.set_block_comment(0xe5a1, "NB: Expects low rom at 0xc000")

    cx.disass(0x1acf)
    cx.disass(0xebf0)

    cx.m.set_block_comment(0x003b9, "Outputs $0x0c - Term (not comma)")
    cx.m.set_block_comment(0x003b9, "Outputs $0x12 - Error")
    cx.m.set_block_comment(0x003b9, "Outputs $0x1a = 0")
    cx.m.set_block_comment(0x003b9, "Outputs $0x1b - Digits")
    cx.m.set_block_comment(0x003b9, "Outputs $0x1f - Decimals")
    cx.m.set_block_comment(0x003b9, "Outputs $0x27 - Negative")
    cx.m.set_block_comment(0x003b9, "Outputs $0x31+32 - Number")
    cx.m.set_block_comment(0xf895, "Set reset, clear interrupt, Clr reset")

    return NAME, (cx.m, )
Esempio n. 8
0
 def txl(seg, a):
     for i in range(2, 0x22, 2):
         x = cx.m.lu16(a + i)
         #print("%04x" % seg, i, "%05x" % (a + i), "%04x" % x, "%05x" % (seg * 16 + x))
         y = data.Codeptr(cx.m, a + i, a + i + 2, seg * 16 + x)
Esempio n. 9
0
 def codeptr(self, adr):
     t = self.m.lu16(adr)
     c = data.Codeptr(self.m, adr, adr + 2, t)
     self.disass(t)
     return c
Esempio n. 10
0
 def codeptr(self, pj, adr):
     t = pj.m.lu32(adr)
     c = data.Codeptr(pj.m, adr, adr + 4, t)
     self.disass(pj.m, t)
     return c
Esempio n. 11
0
def task(pj, cpu):
	gpu = hp1345a.hp1345a()

	cpu.vectors(pj)

	if True:
		# screen texts
		a = 0xd95
		while a < 0xf4d:
			z = Scrtxt(pj, a)
			a = z.hi
			continue
			y = data.Pstruct(pj, a, ">HH")
			y = data.Pstruct(pj, a + 4, ">bbb")
			l = pj.m.bu16(a)
			y = data.Txt(pj, a + 7, a + 7 + l, align=1)
			a += 7 + l

		Scrtxt(pj, 0x01db)
		Scrtxt(pj, 0xea56)
		Scrtxt(pj, 0xea6a)
		Scrtxt(pj, 0xea7d)
		Scrtxt(pj, 0xee37)
		Scrtxt(pj, 0xee51)
		Scrtxt(pj, 0xfa6d)

	if True:
		n = 0
		c = {}
		while pj.m.bu16(0xfd0 + n):
			y = data.Txt(pj, 0xfd0 + n, 0xfd0 + n + 2, align=1)
			ta = 0x1062 + n
			t = pj.m.bu16(ta)
			z = data.Codeptr(pj, ta, ta + 2, t)
			z.lcmt += y.txt
			pj.todo(t, cpu.disass)
			if t not in c:
				c[t] = []
			if y.txt not in CMDS:
				print("Undoc command", y.txt)
				CMDS[y.txt] = [t, "???"]
			else:
				CMDS[y.txt][0] = t
			c[t].append(y.txt)
			n += 2
		for i in c:
			c[i].sort()
			pj.set_label(i, "CMD_" + "_".join(c[i]))

		for i in CMDS:
			c = CMDS[i]
			if c[0] == 0:
				print(i, "CMD not implemented (" + c[1] + ")")
				continue
			if c[1][0] == "?":
				print(i, "CMD not documented (%s)" % c[1][1:])
			pj.set_block_comment(c[0],
				" COMMAND " + i + " - " + c[1])

	if True:
		for a in (0x129d, 0x17e3, 0x181e, 0xe0e3, 0xee7e):
			w = pj.m.rd(a + 1) + 1
			t = pj.m.bu16(a + 4)
			for i in range(w):
				d = pj.m.bu16(t)
				data.Codeptr(pj, t, t + 2, d)
				pj.todo(d, cpu.disass)
				t += 2

	if True:
		# Random strings
		ttab(pj, 0xf019, 0xf03b)
		ttab(pj, 0xf1d1, 0xf25c)
		ttab(pj, 0xf412, 0xf44c)
		ttab(pj, 0xefd7, 0xeff7)

	if True:
		a = 0xf56e
		while pj.m.rd(a):
			y = data.Txt(pj, a, a + 6, label=False, align=1)
			a = y.hi

	if True:
		for a in range(0xf811, 0xf825, 2):
			d = pj.m.bu16(a)
			data.Codeptr(pj, a, a + 2, d)
			pj.todo(d, cpu.disass)

	if True:
		# HP1345 testpatterns
		pj.set_label(0xfbed, "IMG_PIKES_PEAK")
		pj.set_label(0xfd41, "IMG_FOCUS")
		for a0 in (0xfbed, 0xfd41):
			a = a0
			data.Const(pj, a, a + 2,
				func=pj.m.bu16, fmt="0x%x", size=2)
			l = pj.m.bu16(a)
			a += 2
			hp1345_render.svg(pj, a, a + l*2)
			while l > 0:
				gpu.disass(pj, a)
				a += 2
				l -= 1

	if True:
		# No idea, possibly length error in IMG_FOCUS ?
		data.Const(pj, 0xff17, 0xff19, fmt="0x%04x", func=pj.m.bu16, size=2)

	if True:
		# Special character handling
		b = 0xf75b
		c = 0xf778
		pj.set_label(b, "CHR_TBL_KEY")
		pj.set_label(c, "CHR_TBL_PTR")
		data.Const(pj, b, c, fmt="0x%x")
		a = c
		while b < c:
			p = pj.m.bu16(a)
			y = data.Dataptr(pj, a, a + 2, p)
			pj.set_label(p, "CHR_TBL_%02x" % pj.m.rd(b))
			while True:
				z = data.Const(pj, p, p + 2,
				    func=pj.m.bu16, fmt="0x%x", size=2)
				if pj.m.rd(p + 1) & 0x80:
					break
				p += 2
			b += 1
			a += 2

	# Stuff not accessed from anywhere

	pj.todo(0xe5a1, cpu.disass)
	pj.set_label(0xe5a1, "BOGO_TEST_ROM")
	pj.set_block_comment(0xe5a1, "Unused ROM checksum code")
	pj.set_block_comment(0xe5a1, "NB: Expects low rom at 0xc000")

	pj.set_label(0xe5ed, "TEST_IMGRAM")

	pj.todo(0xebf0, cpu.disass)

	while pj.run():
		pass

	pj.set_label(0x0291, "A=GETCHAR()")
	pj.set_label(0x02d0, "PUTCHAR(A)")
	pj.set_label(0x0312, "Y=FIND_CMD()")
	pj.set_label(0x0338, "CLEAR_SCREEN()")
	pj.set_label(0x0395, "PUTSTR(',')")
	pj.set_label(0x039a, "PUTSTR(CRNL)")
	pj.set_label(0x03a9, "memcpy(Y,X+2,@X)")
	pj.set_label(0x03b9, "GETNBR()")
	pj.set_block_comment(0x003b9, "Outputs $0x0c - Term (not comma)")
	pj.set_block_comment(0x003b9, "Outputs $0x12 - Error")
	pj.set_block_comment(0x003b9, "Outputs $0x1a = 0")
	pj.set_block_comment(0x003b9, "Outputs $0x1b - Digits")
	pj.set_block_comment(0x003b9, "Outputs $0x1f - Decimals")
	pj.set_block_comment(0x003b9, "Outputs $0x27 - Negative")
	pj.set_block_comment(0x003b9, "Outputs $0x31+32 - Number")
	pj.set_label(0x04a2, "PUTNBR(D)")
	pj.set_label(0x0bcb, "ERR_1_UNKNOWN_INSN()")
	pj.set_label(0x0bdc, "ERR_2_WRONG_NO_PARAMS()")
	pj.set_label(0x0bed, "ERR_3_XXX_OUT_OF_RANGE()")
	pj.set_label(0x0c2e, "ERR_4_ILLEGAL_CHAR()")
	pj.set_label(0x0c41, "ERR_11_NO_PLOTTER_HANDSHAKE()")
	pj.set_label(0x0c5d, "ERR_12_UNRECOG_PLOTTER()")
	pj.set_label(0x0c79, "ERR_22_FILE_NOT_OPEN_ON()")
	pj.set_label(0x0c8c, "ERR_24_NOT_IN_SCROLL_MODE()")
	pj.set_label(0x0c9f, "ERR_25_MEMORY_NOT_INIT()")
	pj.set_label(0x0cb2, "ERR_32_ALL_FILES_NOT_CONFIG()")
	pj.set_label(0x0cc5, "ERR_33_NO_DATA_TO_SCROLL()")
	pj.set_label(0x0cd8, "ERR_34_MEMORY_OVERFLOW_ON()")
	pj.set_label(0x0ceb, "ERR_35_FILE_ALREADY_OPEN_ON()")
	pj.set_label(0x0f4e, "SCR_MSG(X)")
	pj.set_label(0x0f77, "X = PREP_SCREEN()")
	pj.set_label(0x0f8e, "D = ADR2JMP(D)") 
	pj.set_label(0x0fac, "DELAY(@U)")
	pj.set_label(0x2800, "dip_switch")
	pj.set_label(0xe77e, "CMD_nop")
	pj.set_label(0xef76, "PLOT_pu_sp_lt()")
	pj.set_label(0xef90, "PLOT_SELECT_PEN(A)")
	pj.set_label(0xefb9, "PLOT_LINE_TYPE(A)")
	pj.set_label(0xf004, "PUTSTR(X+1,@X)")
	pj.set_label(0xf0c0, "SPEC_CHAR()")
	pj.set_label(0xf56e, "plotter_table")
	pj.set_label(0xf7fd, "DIAG_MODE()")
	pj.set_label(0xf825, "DIAG_HPIB_BACK2BACK()")
	pj.set_label(0xf895, "HPIB_RESET_CHIPS()")
	pj.set_label(0xf8ae, "HPIB_IFC()")
	pj.set_block_comment(0xf895, "Set reset, clear interrupt, Clr reset")
	pj.set_label(0xfa9f, "DIAG_SIGNATURE_EPROM1()")
	pj.set_label(0xfaaf, "DIAG_SIGNATURE_EPROM2()")
	pj.set_label(0xfac2, "DIAG_SIGNATURE_3000()")
	pj.set_label(0xfade, "DIAG_SIGNATURE_RAM()")
	pj.set_label(0xfaee, "DIAG_RAM()")
	pj.set_label(0xfb03, "DIAG_IMGRAM()")
	pj.set_label(0xfbcb, "DIAG_PIKES_PEAK()")
	pj.set_label(0xfbdc, "DIAG_FOCUS()")
Esempio n. 12
0
 def codeptr(self, adr):
     y = data.Codeptr(self.m, adr, adr + 4, self.m.bu32(adr) & 0x7f00ffff)
     self.disass(y.dst)
     return y