Beispiel #1
0
def task(pj, cpu):
	seven_segment.table(pj, 0x7fbf, 0x7fda, verbose=False)

	ct = utils.cmd_tbl(pj, 0x6225, 0x6287)
	print(ct)

	while pj.run():
		pass
Beispiel #2
0
def task(pj, cpu):
	seven_segment.table(pj, 0x7fbf, 0x7fda, verbose=False)

	ct = utils.cmd_tbl(pj, 0x6225, 0x6287)
	print(ct)

	while pj.run():
		pass
Beispiel #3
0
def task(pj, cpu):

    seven_segment.table(pj, 0x7e29, 0x7e39, verbose=False)

    ct = utils.cmd_tbl(pj, 0x7c5d, 0x7c91)
    cta = utils.arg_range(pj, ct, 0x7d65, 0x7d81)
    utils.cmd_dispatch(pj, cpu, cta, 0x644c)

    pj.set_label(0x66ea, "ERR5_UNDEF_KEY")
    utils.key_dispatch(pj, cpu, 0x640c, 0x644c)

    utils.dsp_dispatch(pj, cpu, 0x6848, 0x6858)

    for i in (0x614c, 0x619c, 0x61a3, 0x69dd, 0x69e4):
        utils.float70(pj, i)

    utils.square_tbl(pj)

    while pj.run():
        pass

    utils.apply_labels(pj, "A")
    utils.tramp(pj)
Beispiel #4
0
def task(pj, cpu):

	seven_segment.table(pj, 0x7e29, 0x7e39, verbose=False)

	ct = utils.cmd_tbl(pj, 0x7c5d, 0x7c91)
	cta = utils.arg_range(pj, ct, 0x7d65, 0x7d81)
	utils.cmd_dispatch(pj, cpu, cta, 0x644c)

	pj.set_label(0x66ea, "ERR5_UNDEF_KEY")
	utils.key_dispatch(pj, cpu, 0x640c, 0x644c)

	utils.dsp_dispatch(pj, cpu, 0x6848, 0x6858)

	for i in (0x614c, 0x619c, 0x61a3, 0x69dd, 0x69e4):
		utils.float70(pj, i)

	utils.square_tbl(pj)

	while pj.run():
		pass

	utils.apply_labels(pj, "A")
	utils.tramp(pj)
Beispiel #5
0
def task(pj, cpu):

    #######################################################################

    def rom(lo, hi):
        pj.add(lo, hi, "ROM")
        s = 0
        for a in range(lo, hi):
            s += pj.m.rd(a)
        s &= 0xFF
        if s == 0:
            print("ROM %04x-%04x sum good (%02x)" % (lo, hi, s))
        else:
            print("ROM %04x-%04x sum BAD (%02x)" % (lo, hi, s))

    rom(0x6800, 0x7000)
    rom(0x7000, 0x7800)
    rom(0x7800, 0x8000)

    for i in (0x6FFF, 0x77FF, 0x7FF7):
        c = pj.add(i, i + 1, "csum")
        c.rendered = c.tag

        #######################################################################

    def vec(a, n):
        c = pj.add(a, a + 2, "vector")
        c.rendered = "vector(%s)" % n
        v = pj.m.bu16(a)
        pj.todo(v, cpu.disass)

    vec(0x7FF8, "IRQ")
    vec(0x7FFA, "SWI")
    vec(0x7FFC, "NMI")
    vec(0x7FFE, "RST")

    #######################################################################

    class ptr(job.Leaf):
        def __init__(self, pj, adr):
            super(ptr, self).__init__(pj, adr, adr + 2, "ptr")
            pj.insert(self)

        def render(self, pj):
            v = pj.m.bu16(self.lo)
            l = pj.labels.get(v)
            if l == None:
                return ".PTR 0x%x" % v
            else:
                return ".PTR %s" % l

    def jmptbl(lo, hi, x=None):
        c = pj.add(lo, hi, "jmptbl (%04x-%04x)" % (lo, hi))
        # c.rendered = c.tag
        n = 0
        for a in range(lo, hi, 2):
            v = pj.m.bu16(a)
            d = ptr(pj, a)
            if x != None and len(x) > n:
                if v not in symbols:
                    symbols[v] = "CMD_" + x[n]
            n += 1
            pj.todo(v, cpu.disass)

    jmptbl(0x7768, 0x77B6, "9876543210.-@ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    jmptbl(0x7860, 0x787C)
    jmptbl(0x78A0, 0x78BC)
    jmptbl(0x78C0, 0x78DC)

    #######################################################################

    def tblx(a):
        c = pj.add(a, a + 16, "tblx")
        s = ""
        for i in range(10):
            v = pj.m.rd(a + i)
            s += " %02x" % v
        s += "  "
        for i in range(10, 16):
            v = pj.m.rd(a + i)
            s += " %02x" % v
        c.rendered = "TBLX " + s
        c.compact = True

    for a in range(0x7000, 0x70A0, 16):
        tblx(a)

    for a in range(0x7100, 0x71A0, 16):
        tblx(a)

        #######################################################################

        # seven_segment.hunt(pj, 0x6800, 0x8000, pattern="AbCdE")
        # seven_segment.hunt(pj, 0x6800, 0x8000)

    seven_segment.table(pj, 0x7800, 0x7810, map=(128, 64, 32, 16, 8, 4, 2, 1, 0), inv=True, verbose=False)

    #######################################################################
    if True:
        for a, l in symbols.items():
            pj.set_label(a, l)

    while pj.run():
        pass
Beispiel #6
0
def task(pj, cx):
    cx.register_labels(pj)

    cx.vectors(pj)

    def cbyte(pj, a):
        c = data.Const(pj, a, a + 1)
        c.val = pj.m.rd(a)
        c.typ = ".BYTE"
        c.fmt = "0x%02x" % c.val
        return c

    def cword(pj, a):
        c = data.Const(pj, a, a + 2)
        c.val = pj.m.bu16(a)
        c.typ = ".WORD"
        c.fmt = "0x%04x" % c.val
        return c

    class d_chain(data.Data):
        def __init__(self, pj, a):
            super(d_chain, self).__init__(pj, a, a + 4)
            self.num = '%c%c%c' % (
                pj.m.rd(self.lo),
                pj.m.rd(self.lo + 1),
                pj.m.rd(self.lo + 2),
            )

        def render(self, pj):
            return ".STRUCT chain { '%c%c%c', %d }" % (
                pj.m.rd(self.lo),
                pj.m.rd(self.lo + 1),
                pj.m.rd(self.lo + 2),
                pj.m.rd(self.lo + 3),
            )

    class d_asf(data.Data):
        def __init__(self, pj, a):
            super(d_asf, self).__init__(pj, a, a + 16)

        def render(self, pj):
            s = ".STRUCT asf {"
            t = " "
            for i in range(0, 16, 2):
                s += t + "%6d" % pj.m.bu16(self.lo + i)
                t = ", "
            s += "}"
            return s

    class d_q(data.Data):
        """
		Numbers are sign + 31 bit binary q-complement fractions:
			[Sign][31 bit fraction]
		"""
        def __init__(self, pj, a, lbl=True):
            if pj.find(a, ".D4") != None:
                return
            super(d_q, self).__init__(pj, a, a + 4, ".D4")
            self.val = pj.m.bu32(a)
            self.dec = self.val
            if self.dec & 0x80000000:
                self.dec &= 0x7fffffff
                self.dec *= -1
            self.dec *= 2**-31
            if lbl:
                pj.set_label(self.lo, "Q_%04x_%g" % (self.lo, self.dec))

        def render(self, pj):
            if self.dec != 0.0:
                b = 1.0 / self.dec
            else:
                b = 0.
            return ".D4 %12g = 1/%g" % (self.dec, b)

    #######################################################################

    led_map = [1, 2, 4, 128, 64, 16, 32, 8, 0]

    seven_segment.table(pj, 0xecb4, 0xecd4, map=led_map, verbose=False)
    pj.set_label(0xecb4, "7SEG_TBL")

    LED_lbl = {
        0xf94d: "_PL-99___LORAN-C",
        0xf95d: "__Progr____PL-15",
        0xf96d: "_Please___Choose",
        0xf97d: "Lat-Lon___or_Gri",
        0xf98d: "__L-L=4____Gri=7",
        0xf99d: "Enter____Gri____",
        0xf9ad: "Enter____Lat-Lon",
        0xf9bd: "________________",
        0xf9cd: "_Enter___Fn_no__",
        0xf9dd: "_______A_Gri___0",
        0xf9ed: "Search_A_Gri___0",
        0xf9fd: "SAVE_in_____no__",
        0xfa0d: "___no_______Fn__",
        0xfa1d: "_________CAL____",
        0xfa2d: "Enter______deg__",
        0xfa3d: "8888888888888888",
        0xfa4d: "Oscil___________",
        0xfa5d: "__AREA____CHANGE",
        0xfa6d: "__Pri=1____Alt=4",
        0xfa7d: "_reset___spd_fil",
        0xfa8d: "__speed___filter",
        0xfa9d: "__slo_____15_set",
        0xfaad: "regular___15_set",
        0xfabd: "___fast___15_set",
        0xfacd: "__slo=1____reg=2",
        0xfadd: "_fast=3__A5_15=C",
        0xfaed: "display_____no__",
        0xfafd: "_Go_to______no__",
        0xfb0d: "no_ASF___Entered",
        0xfb1d: "__ASF____Entered",
        0xfb2d: "CHANGE_____by__0",
        0xfb3d: "Enter____ASF____",
        0xfb4d: "Enter_______no__",
        0xfb5d: "1_For0___2_For00",
        0xfb6d: "Start_______no__",
        0xfb7d: "__L-L=4____tds=7",
        0xfb8d: "________________",
        0xfb9d: "_fast____Average",
        0xfbad: "regular__Average",
        0xfbbd: "__Light_____on__",
        0xfbcd: "__Light_____off_",
        0xfbdd: "_dest_______no__",
        0xfbed: "Select______no__",
        0xfbfd: "__________Cntr__",
        0xfc0d: "_____00__set_CL_",
        0xfc1d: "_____00_____CL0C",
        0xfc2d: "_____00__set_ttG",
        0xfc3d: "_____00______ttG",
        0xfc4d: "ASF______Entr___",
        0xfc5d: "Arr_0____dist___",
        0xfc6d: "Anchor______no__",
        0xfc7d: "Anchor____dist__",
        0xfc8d: "set_0____d55____",
        0xfc9d: "Clr_cyc___Error_",
        0xfcad: "__Plan______Fn__",
        0xfcbd: "_CHANGE____Gri__",
        0xfccd: "_Cold_____Start_",
        0xfcdd: "reStart_________",
        0xfced: "__YE5=1_____no=4",
        0xfcfd: "reset____hot_t__",
        0xfd0d: "reset____cold_t_",
        0xfd1d: "__route_____no__",
        0xfd2d: "__route_____no-_",
        0xfd3d: "__Use=1__displ=4",
        0xfd4d: "Pt___15___done=4",
        0xfd5d: "__End=1___Cont=4",
        0xfd6d: "speed____display",
        0xfd7d: "_Crse=1___Grnd=4",
        0xfd8d: "set_brg___corr=0",
        0xfd9d: "_Seed____Lat-Lon",
        0xfdad: "_Output__data_on",
        0xfdbd: "_Output__dataoff",
        0xfdcd: "_Auto=1____not=4",
        0xfddd: "_Clear_____ASF__",
        0xfded: "Input____OSC____",
        0xfdfd: "___SELF_____TRAC",
    }

    for a in range(0xf94d, 0xfdfe, 16):
        c = seven_segment.table(pj, a, a + 16, map=led_map, verbose=False)
        t = LED_lbl.get(a)
        assert t != None
        if t == None:
            # Try to construct a string ourselves...
            t = ""
            for i in c:
                if i == None:
                    t += "?"
                elif len(i) == 1:
                    t += i
                elif i == "blank":
                    t += "_"
                else:
                    t += "?"
        pj.set_label(a, "MSG_" + t)

    #######################################################################
    def post_arg_func(pj, ins):
        post_arg_funcs = {
            0xb80c: "WB",
            0xb821: "WB",
            0xb836: "W",
            0xb846: "WWW",
            0xb86c: "WWW",
            0xb892: "WWW",
            0xb989: "WWW",
            0xbabc: "WW",
            0xbb60: "WWW",
            0xbca1: "WWW",
            0xbdeb: "WW",
        }
        for f in ins.flow_out:
            i = post_arg_funcs.get(f.to)
            if i == None:
                continue
            ins.flow_out = []
            ins.add_flow(pj, "C", True, f.to)
            a = ins.hi
            for j in i:
                if j == "W":
                    d = pj.m.bu16(a)
                    data.Dataptr(pj, a, a + 2, d)
                    a += 2
                    if d >= 0x8000:
                        d_q(pj, d)
                elif j == "B":
                    cbyte(pj, a)
                    # data.Data(pj, a, a + 1)
                    a += 1
                else:
                    assert False
            ins.add_flow(pj, ">", True, a)
            return

    cx.flow_check.append(post_arg_func)

    #######################################################################

    def bogo_flow(pj, ins):
        for f in ins.flow_out:
            if f.to == None:
                pass
            elif f.to < 0x8000 or f.to > 0xffff:
                print("BOGO", ins)

    cx.flow_check.append(bogo_flow)

    #######################################################################

    chains = []
    x = pj.add(0x9d20, 0x9d68, "chain-tbl")
    pj.set_label(x.lo, "CHAINS")
    for a in range(x.lo, x.hi, 4):
        chains.append("GRI_" + d_chain(pj, a).num + "0")
    """
	This is probably ASF data
	(Based partially on number of records = 204)
	"""
    x = pj.add(0x9d68, 0xaa28, "asf-tbl")
    for a in range(x.lo, x.hi, 16):
        d_asf(pj, a)

    # ON_KEY table
    x = pj.add(0xe072, 0xe0e2, "on-key-tbl")
    pj.set_label(x.lo, "ON_KEY_TBL")
    n = 0x80
    for a in range(x.lo, x.hi, 2):
        x = cx.codeptr(pj, a)
        pj.set_label(x.dst, "ON_KEY_0x%02x" % n)
        n += 1

    # CMD table
    x = pj.add(0x9b81, 0x9bff, "cmd-tbl")
    pj.set_label(x.lo, "CMDTBL")
    for a in range(x.lo, x.hi, 3):
        y = data.Txt(pj, a, a + 1, label=False)
        z = cx.codeptr(pj, a + 1)
        if y.txt == " ":
            pj.set_label(z.dst, "CMD_SP")
        else:
            pj.set_label(z.dst, "CMD_%s" % y.txt)

    # FN table
    x = pj.add(0xf885, 0xf94d, "fn-tbl")
    pj.set_label(x.lo, "FN_TBL")
    d = dict()
    n = 0
    for a in range(x.lo, x.hi, 2):
        y = cx.codeptr(pj, a)
        if not y.dst in d:
            d[y.dst] = []
        d[y.dst].append(n)
        n += 1
    for i in d:
        e = d[i]
        if len(e) == 1:
            pj.set_label(i, "FN_%02d" % e[0])
        elif len(e) > 10:
            pj.set_label(i, "FN_UNDEF")
        else:
            pj.set_label(i, "FN_%02d_%02d" % (e[0], e[-1]))

    def longitude(pj, a):
        """
		This gives values closely matching table values
		"""
        x = d_q(pj, a, lbl=False)
        s = ""
        v = x.dec * 180.
        if v < 0:
            v *= -1
            s += "W"
            v = 180. - v
        else:
            s += "E"
        deg = v.__trunc__()
        v -= deg
        s += "%4d" % deg

        v *= 60
        mi = v.__trunc__()
        v -= mi
        s += " %2d'" % mi

        v *= 60
        s += ' %2.3f"' % v

        x.lcmt = s
        return x

    def lattitude(pj, a):
        """
		This calculation is not quite right.
		"""
        x = d_q(pj, a, lbl=False)
        s = ""
        v = x.dec * 90.
        v = 108 - v
        if v < 0:
            v *= -1
            s += "S"
            v = 180. - v
        else:
            s += "N"
        deg = v.__trunc__()
        v -= deg
        s += "%4d" % deg

        v *= 60
        mi = v.__trunc__()
        v -= mi
        s += " %2d'" % mi

        v *= 60
        s += ' %2.3f"' % v

        x.lcmt = s
        return x

    #
    # Chain data, idx'ed by 0x9d20
    #
    x = pj.add(0xaa29, 0xb131, "tbl")
    n = 0
    for a in range(x.lo, x.hi, 100):
        x = pj.add(a, a + 100, "chain-tbl")
        pj.set_label(a, "CHAIN_" + chains[n])
        x = cword(pj, a)
        x.lcmt = "GRI %d * 5" % (x.val / 5)
        #data.Data(pj, a, a + 100)
        x = pj.add(a + 0x02, a + 0x02 + 5 * 4, "alpha-tbl")
        x = pj.add(a + 0x16, a + 0x16 + 5 * 4, "beta-tbl")
        x = pj.add(a + 0x2a, a + 0x2a + 5 * 4, "gamma-tbl")
        for c in range(5):
            d_q(pj, a + 0x02 + c * 4, lbl=False)
            lat = lattitude(pj, a + 0x16 + c * 4)
            lon = longitude(pj, a + 0x2a + c * 4)

        x = pj.add(a + 0x3e, a + 0x3e + 4 * 4, "rho-tbl")
        x = pj.add(a + 0x4e, a + 0x4e + 4 * 4, "sigma-tbl")
        for c in range(4):
            x = d_q(pj, a + 0x3e + c * 4, lbl=False)
            x.lcmt = "%.3f us / 2^23" % (x.dec * 2**23)
            d_q(pj, a + 0x4e + c * 4, lbl=False)

        x = pj.add(a + 0x5e, a + 0x5e + 5, "epsilon-tbl")
        for c in range(5):
            cbyte(pj, a + 0x5e + c)

        x = cbyte(pj, a + 99)
        x.lcmt = "# slaves"
        n += 1

    for a in range(0xc2fe, 0xc38e, 4):
        d_q(pj, a)

    # idx into tbl at b156
    # Chain data (18 pieces)
    #
    x = pj.add(0xb132, 0xb155, "tbl")
    n = 0
    for a in range(x.lo, x.hi, 2):
        y = cword(pj, a)
        y.lcmt = chains[n]
        pj.set_label(0xb156 + y.val, "CHAIN_I_" + chains[n])
        n += 1

    x = pj.add(0xb156, 0xb43e, "tbl")
    for a in range(x.lo, x.hi, 4):
        #data.Data(pj, a, a + 4)
        d_q(pj, a, lbl=False)

    for a in range(0xc3a6, 0xc41e, 4):
        d_q(pj, a)

    for a in range(0x906f, 0x9087, 2):
        c = cword(pj, a)
        c.fmt = "%d" % c.val

    x = pj.add(0x9d00, 0x9d20, "tbl")
    x.lcmt += "accessed via 0x9cc2 pointer"
    for a in range(x.lo, x.hi, 2):
        c = cword(pj, a)

    pj.todo(0x9102, cx.disass)
    pj.todo(0x95da, cx.disass)
    pj.todo(0x9b29, cx.disass)
    pj.todo(0x9a96, cx.disass)
    pj.todo(0x9b44, cx.disass)
    pj.todo(0x9b57, cx.disass)
    pj.todo(0xdda1, cx.disass)
    pj.todo(0xdde0, cx.disass)
    pj.todo(0xde00, cx.disass)
    pj.todo(0xde20, cx.disass)
    pj.todo(0xf719, cx.disass)

    for a in range(0x9789, 0x97a5, 4):
        d_q(pj, a)

    for i in range(0xf220, 0xf226, 2):
        data.Dataptr(pj, i, i + 2, pj.m.bu16(i))
        cword(pj, i + 6)

    #for i in range(0x89d8, 0x8a20, 2):
    #	data.Dataptr(pj, i, i + 2, pj.m.bu16(i))

    for i in range(0xe363, 0xe369, 2):
        x = cx.codeptr(pj, i)

    x = pj.add(0xb963, 0xb975, "tbl")
    for i in range(x.lo, x.hi):
        cbyte(pj, i)

    data.Data(pj, 0xca73, 0xca7c)

    data.Data(pj, 0xec7c, 0xec81)
    data.Data(pj, 0xec81, 0xec85)
    data.Data(pj, 0xec85, 0xec8b)
    data.Data(pj, 0xec8b, 0xec91)

    d_q(pj, 0xcb70)
    d_q(pj, 0xd4f5)
    d_q(pj, 0xd4f9)
    d_q(pj, 0xd4fd)
    d_q(pj, 0xd501)

    while pj.run():
        pass

    pj.set_label(0x6489, "CHAIN_PTR")

    pj.set_label(0xb800, "MEMCPY(X, Y, B)")
    pj.set_label(0xb80c, "SHR_Q")
    pj.set_label(0xb821, "SHL_Q")
    pj.set_label(0xb836, "COM_Q")
    pj.set_label(0xb846, "ADD_Q")
    pj.set_label(0xb86c, "SUB_Q")
    pj.set_label(0xb892, "MUL_Q")

    pj.set_label(0xec91, "7SEG_XLAT(0x66a9)")
    pj.set_label(0xecaa, "7SEG_DIG(B)")

    pj.set_label(0xecd4, "DISPLAY(Y)")

    pj.set_label(0xf1a9, "DISPLAY_YES_NO(Y)")
    pj.set_label(0xf1b7, "IS_YES()")
    pj.set_label(0xf878, "PAUSE()")
    pj.set_label(0xfe5c, "Analog_Capture")
    pj.set_label(0xfe6e, "Capture_One_Analog")

    pj.set_label(0xf9, "ON_KEY")
Beispiel #7
0
def task(pj, cpu):

    #######################################################################

    def rom(lo, hi):
        pj.add(lo, hi, "ROM")
        s = 0
        for a in range(lo, hi):
            s += pj.m.rd(a)
        s &= 0xff
        if s == 0:
            print("ROM %04x-%04x sum good (%02x)" % (lo, hi, s))
        else:
            print("ROM %04x-%04x sum BAD (%02x)" % (lo, hi, s))

    rom(0x6800, 0x7000)
    rom(0x7000, 0x7800)
    rom(0x7800, 0x8000)

    for i in (0x6fff, 0x77ff, 0x7ff7):
        c = pj.add(i, i + 1, "csum")
        c.rendered = c.tag

    #######################################################################

    def vec(a, n):
        c = pj.add(a, a + 2, "vector")
        c.rendered = "vector(%s)" % n
        v = pj.m.bu16(a)
        pj.todo(v, cpu.disass)

    vec(0x7ff8, "IRQ")
    vec(0x7ffa, "SWI")
    vec(0x7ffc, "NMI")
    vec(0x7ffe, "RST")

    #######################################################################

    class ptr(job.Leaf):
        def __init__(self, pj, adr):
            super(ptr, self).__init__(pj, adr, adr + 2, "ptr")
            pj.insert(self)

        def render(self, pj):
            v = pj.m.bu16(self.lo)
            l = pj.labels.get(v)
            if l == None:
                return ".PTR 0x%x" % v
            else:
                return ".PTR %s" % l

    def jmptbl(lo, hi, x=None):
        c = pj.add(lo, hi, "jmptbl (%04x-%04x)" % (lo, hi))
        # c.rendered = c.tag
        n = 0
        for a in range(lo, hi, 2):
            v = pj.m.bu16(a)
            d = ptr(pj, a)
            if x != None and len(x) > n:
                if v not in symbols:
                    symbols[v] = "CMD_" + x[n]
            n += 1
            pj.todo(v, cpu.disass)

    jmptbl(0x7768, 0x77b6, '9876543210.-@ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    jmptbl(0x7860, 0x787c)
    jmptbl(0x78a0, 0x78bc)
    jmptbl(0x78c0, 0x78dc)

    #######################################################################

    def tblx(a):
        c = pj.add(a, a + 16, "tblx")
        s = ""
        for i in range(10):
            v = pj.m.rd(a + i)
            s += " %02x" % v
        s += "  "
        for i in range(10, 16):
            v = pj.m.rd(a + i)
            s += " %02x" % v
        c.rendered = "TBLX " + s
        c.compact = True

    for a in range(0x7000, 0x70a0, 16):
        tblx(a)

    for a in range(0x7100, 0x71a0, 16):
        tblx(a)

    #######################################################################

    #seven_segment.hunt(pj, 0x6800, 0x8000, pattern="AbCdE")
    #seven_segment.hunt(pj, 0x6800, 0x8000)

    seven_segment.table(pj,
                        0x7800,
                        0x7810,
                        map=(128, 64, 32, 16, 8, 4, 2, 1, 0),
                        inv=True,
                        verbose=False)

    #######################################################################
    if True:
        for a, l in symbols.items():
            pj.set_label(a, l)

    while pj.run():
        pass
Beispiel #8
0
def task(pj, cx):
    cx.register_labels(pj)

    cx.vectors(pj)

    def cbyte(pj, a):
        c = data.Const(pj, a, a + 1)
        c.val = pj.m.rd(a)
        c.typ = ".BYTE"
        c.fmt = "0x%02x" % c.val
        return c

    def cword(pj, a):
        c = data.Const(pj, a, a + 2)
        c.val = pj.m.bu16(a)
        c.typ = ".WORD"
        c.fmt = "0x%04x" % c.val
        return c

    class d_chain(data.Data):
        def __init__(self, pj, a):
            super(d_chain, self).__init__(pj, a, a + 4)
            self.num = "%c%c%c" % (pj.m.rd(self.lo), pj.m.rd(self.lo + 1), pj.m.rd(self.lo + 2))

        def render(self, pj):
            return ".STRUCT chain { '%c%c%c', %d }" % (
                pj.m.rd(self.lo),
                pj.m.rd(self.lo + 1),
                pj.m.rd(self.lo + 2),
                pj.m.rd(self.lo + 3),
            )

    class d_asf(data.Data):
        def __init__(self, pj, a):
            super(d_asf, self).__init__(pj, a, a + 16)

        def render(self, pj):
            s = ".STRUCT asf {"
            t = " "
            for i in range(0, 16, 2):
                s += t + "%6d" % pj.m.bu16(self.lo + i)
                t = ", "
            s += "}"
            return s

    class d_q(data.Data):
        """
		Numbers are sign + 31 bit binary q-complement fractions:
			[Sign][31 bit fraction]
		"""

        def __init__(self, pj, a, lbl=True):
            if pj.find(a, ".D4") != None:
                return
            super(d_q, self).__init__(pj, a, a + 4, ".D4")
            self.val = pj.m.bu32(a)
            self.dec = self.val
            if self.dec & 0x80000000:
                self.dec &= 0x7FFFFFFF
                self.dec *= -1
            self.dec *= 2 ** -31
            if lbl:
                pj.set_label(self.lo, "Q_%04x_%g" % (self.lo, self.dec))

        def render(self, pj):
            if self.dec != 0.0:
                b = 1.0 / self.dec
            else:
                b = 0.0
            return ".D4 %12g = 1/%g" % (self.dec, b)

            #######################################################################

    led_map = [1, 2, 4, 128, 64, 16, 32, 8, 0]

    seven_segment.table(pj, 0xECB4, 0xECD4, map=led_map, verbose=False)
    pj.set_label(0xECB4, "7SEG_TBL")

    LED_lbl = {
        0xF94D: "_PL-99___LORAN-C",
        0xF95D: "__Progr____PL-15",
        0xF96D: "_Please___Choose",
        0xF97D: "Lat-Lon___or_Gri",
        0xF98D: "__L-L=4____Gri=7",
        0xF99D: "Enter____Gri____",
        0xF9AD: "Enter____Lat-Lon",
        0xF9BD: "________________",
        0xF9CD: "_Enter___Fn_no__",
        0xF9DD: "_______A_Gri___0",
        0xF9ED: "Search_A_Gri___0",
        0xF9FD: "SAVE_in_____no__",
        0xFA0D: "___no_______Fn__",
        0xFA1D: "_________CAL____",
        0xFA2D: "Enter______deg__",
        0xFA3D: "8888888888888888",
        0xFA4D: "Oscil___________",
        0xFA5D: "__AREA____CHANGE",
        0xFA6D: "__Pri=1____Alt=4",
        0xFA7D: "_reset___spd_fil",
        0xFA8D: "__speed___filter",
        0xFA9D: "__slo_____15_set",
        0xFAAD: "regular___15_set",
        0xFABD: "___fast___15_set",
        0xFACD: "__slo=1____reg=2",
        0xFADD: "_fast=3__A5_15=C",
        0xFAED: "display_____no__",
        0xFAFD: "_Go_to______no__",
        0xFB0D: "no_ASF___Entered",
        0xFB1D: "__ASF____Entered",
        0xFB2D: "CHANGE_____by__0",
        0xFB3D: "Enter____ASF____",
        0xFB4D: "Enter_______no__",
        0xFB5D: "1_For0___2_For00",
        0xFB6D: "Start_______no__",
        0xFB7D: "__L-L=4____tds=7",
        0xFB8D: "________________",
        0xFB9D: "_fast____Average",
        0xFBAD: "regular__Average",
        0xFBBD: "__Light_____on__",
        0xFBCD: "__Light_____off_",
        0xFBDD: "_dest_______no__",
        0xFBED: "Select______no__",
        0xFBFD: "__________Cntr__",
        0xFC0D: "_____00__set_CL_",
        0xFC1D: "_____00_____CL0C",
        0xFC2D: "_____00__set_ttG",
        0xFC3D: "_____00______ttG",
        0xFC4D: "ASF______Entr___",
        0xFC5D: "Arr_0____dist___",
        0xFC6D: "Anchor______no__",
        0xFC7D: "Anchor____dist__",
        0xFC8D: "set_0____d55____",
        0xFC9D: "Clr_cyc___Error_",
        0xFCAD: "__Plan______Fn__",
        0xFCBD: "_CHANGE____Gri__",
        0xFCCD: "_Cold_____Start_",
        0xFCDD: "reStart_________",
        0xFCED: "__YE5=1_____no=4",
        0xFCFD: "reset____hot_t__",
        0xFD0D: "reset____cold_t_",
        0xFD1D: "__route_____no__",
        0xFD2D: "__route_____no-_",
        0xFD3D: "__Use=1__displ=4",
        0xFD4D: "Pt___15___done=4",
        0xFD5D: "__End=1___Cont=4",
        0xFD6D: "speed____display",
        0xFD7D: "_Crse=1___Grnd=4",
        0xFD8D: "set_brg___corr=0",
        0xFD9D: "_Seed____Lat-Lon",
        0xFDAD: "_Output__data_on",
        0xFDBD: "_Output__dataoff",
        0xFDCD: "_Auto=1____not=4",
        0xFDDD: "_Clear_____ASF__",
        0xFDED: "Input____OSC____",
        0xFDFD: "___SELF_____TRAC",
    }

    for a in range(0xF94D, 0xFDFE, 16):
        c = seven_segment.table(pj, a, a + 16, map=led_map, verbose=False)
        t = LED_lbl.get(a)
        assert t != None
        if t == None:
            # Try to construct a string ourselves...
            t = ""
            for i in c:
                if i == None:
                    t += "?"
                elif len(i) == 1:
                    t += i
                elif i == "blank":
                    t += "_"
                else:
                    t += "?"
        pj.set_label(a, "MSG_" + t)

        #######################################################################

    def post_arg_func(ins):
        post_arg_funcs = {
            0xB80C: "WB",
            0xB821: "WB",
            0xB836: "W",
            0xB846: "WWW",
            0xB86C: "WWW",
            0xB892: "WWW",
            0xB989: "WWW",
            0xBABC: "WW",
            0xBB60: "WWW",
            0xBCA1: "WWW",
            0xBDEB: "WW",
        }
        for f in ins.flow_out:
            i = post_arg_funcs.get(f.to)
            if i == None:
                continue
            ins.flow_out = []
            ins.add_flow(pj, "C", True, f.to)
            a = ins.hi
            for j in i:
                if j == "W":
                    d = pj.m.bu16(a)
                    data.Dataptr(pj, a, a + 2, d)
                    a += 2
                    if d >= 0x8000:
                        d_q(pj, d)
                elif j == "B":
                    cbyte(pj, a)
                    # data.Data(pj, a, a + 1)
                    a += 1
                else:
                    assert False
            ins.add_flow(pj, ">", True, a)
            return

    cx.flow_check.append(post_arg_func)
    #######################################################################

    def bogo_flow(ins):
        for f in ins.flow_out:
            if f.to == None:
                pass
            elif f.to < 0x8000 or f.to > 0xFFFF:
                print("BOGO", ins)

    cx.flow_check.append(bogo_flow)

    #######################################################################

    chains = []
    x = pj.add(0x9D20, 0x9D68, "chain-tbl")
    pj.set_label(x.lo, "CHAINS")
    for a in range(x.lo, x.hi, 4):
        chains.append("GRI_" + d_chain(pj, a).num + "0")

    """
	This is probably ASF data
	(Based partially on number of records = 204)
	"""
    x = pj.add(0x9D68, 0xAA28, "asf-tbl")
    for a in range(x.lo, x.hi, 16):
        d_asf(pj, a)

        # ON_KEY table
    x = pj.add(0xE072, 0xE0E2, "on-key-tbl")
    pj.set_label(x.lo, "ON_KEY_TBL")
    n = 0x80
    for a in range(x.lo, x.hi, 2):
        x = cx.codeptr(pj, a)
        pj.set_label(x.dst, "ON_KEY_0x%02x" % n)
        n += 1

        # CMD table
    x = pj.add(0x9B81, 0x9BFF, "cmd-tbl")
    pj.set_label(x.lo, "CMDTBL")
    for a in range(x.lo, x.hi, 3):
        y = data.Txt(pj, a, a + 1, label=False)
        z = cx.codeptr(pj, a + 1)
        if y.txt == " ":
            pj.set_label(z.dst, "CMD_SP")
        else:
            pj.set_label(z.dst, "CMD_%s" % y.txt)

            # FN table
    x = pj.add(0xF885, 0xF94D, "fn-tbl")
    pj.set_label(x.lo, "FN_TBL")
    d = dict()
    n = 0
    for a in range(x.lo, x.hi, 2):
        y = cx.codeptr(pj, a)
        if not y.dst in d:
            d[y.dst] = []
        d[y.dst].append(n)
        n += 1
    for i in d:
        e = d[i]
        if len(e) == 1:
            pj.set_label(i, "FN_%02d" % e[0])
        elif len(e) > 10:
            pj.set_label(i, "FN_UNDEF")
        else:
            pj.set_label(i, "FN_%02d_%02d" % (e[0], e[-1]))

    def longitude(pj, a):
        """
		This gives values closely matching table values
		"""
        x = d_q(pj, a, lbl=False)
        s = ""
        v = x.dec * 180.0
        if v < 0:
            v *= -1
            s += "W"
            v = 180.0 - v
        else:
            s += "E"
        deg = v.__trunc__()
        v -= deg
        s += "%4d" % deg

        v *= 60
        mi = v.__trunc__()
        v -= mi
        s += " %2d'" % mi

        v *= 60
        s += ' %2.3f"' % v

        x.lcmt = s
        return x

    def lattitude(pj, a):
        """
		This calculation is not quite right.
		"""
        x = d_q(pj, a, lbl=False)
        s = ""
        v = x.dec * 90.0
        v = 108 - v
        if v < 0:
            v *= -1
            s += "S"
            v = 180.0 - v
        else:
            s += "N"
        deg = v.__trunc__()
        v -= deg
        s += "%4d" % deg

        v *= 60
        mi = v.__trunc__()
        v -= mi
        s += " %2d'" % mi

        v *= 60
        s += ' %2.3f"' % v

        x.lcmt = s
        return x

        #
        # Chain data, idx'ed by 0x9d20
        #

    x = pj.add(0xAA29, 0xB131, "tbl")
    n = 0
    for a in range(x.lo, x.hi, 100):
        x = pj.add(a, a + 100, "chain-tbl")
        pj.set_label(a, "CHAIN_" + chains[n])
        x = cword(pj, a)
        x.lcmt = "GRI %d * 5" % (x.val / 5)
        # data.Data(pj, a, a + 100)
        x = pj.add(a + 0x02, a + 0x02 + 5 * 4, "alpha-tbl")
        x = pj.add(a + 0x16, a + 0x16 + 5 * 4, "beta-tbl")
        x = pj.add(a + 0x2A, a + 0x2A + 5 * 4, "gamma-tbl")
        for c in range(5):
            d_q(pj, a + 0x02 + c * 4, lbl=False)
            lat = lattitude(pj, a + 0x16 + c * 4)
            lon = longitude(pj, a + 0x2A + c * 4)

        x = pj.add(a + 0x3E, a + 0x3E + 4 * 4, "rho-tbl")
        x = pj.add(a + 0x4E, a + 0x4E + 4 * 4, "sigma-tbl")
        for c in range(4):
            x = d_q(pj, a + 0x3E + c * 4, lbl=False)
            x.lcmt = "%.3f us / 2^23" % (x.dec * 2 ** 23)
            d_q(pj, a + 0x4E + c * 4, lbl=False)

        x = pj.add(a + 0x5E, a + 0x5E + 5, "epsilon-tbl")
        for c in range(5):
            cbyte(pj, a + 0x5E + c)

        x = cbyte(pj, a + 99)
        x.lcmt = "# slaves"
        n += 1

    for a in range(0xC2FE, 0xC38E, 4):
        d_q(pj, a)

        # idx into tbl at b156
        # Chain data (18 pieces)
        #
    x = pj.add(0xB132, 0xB155, "tbl")
    n = 0
    for a in range(x.lo, x.hi, 2):
        y = cword(pj, a)
        y.lcmt = chains[n]
        pj.set_label(0xB156 + y.val, "CHAIN_I_" + chains[n])
        n += 1

    x = pj.add(0xB156, 0xB43E, "tbl")
    for a in range(x.lo, x.hi, 4):
        # data.Data(pj, a, a + 4)
        d_q(pj, a, lbl=False)

    for a in range(0xC3A6, 0xC41E, 4):
        d_q(pj, a)

    for a in range(0x906F, 0x9087, 2):
        c = cword(pj, a)
        c.fmt = "%d" % c.val

    x = pj.add(0x9D00, 0x9D20, "tbl")
    x.lcmt += "accessed via 0x9cc2 pointer"
    for a in range(x.lo, x.hi, 2):
        c = cword(pj, a)

    pj.todo(0x9102, cx.disass)
    pj.todo(0x95DA, cx.disass)
    pj.todo(0x9B29, cx.disass)
    pj.todo(0x9A96, cx.disass)
    pj.todo(0x9B44, cx.disass)
    pj.todo(0x9B57, cx.disass)
    pj.todo(0xDDA1, cx.disass)
    pj.todo(0xDDE0, cx.disass)
    pj.todo(0xDE00, cx.disass)
    pj.todo(0xDE20, cx.disass)
    pj.todo(0xF719, cx.disass)

    for a in range(0x9789, 0x97A5, 4):
        d_q(pj, a)

    for i in range(0xF220, 0xF226, 2):
        data.Dataptr(pj, i, i + 2, pj.m.bu16(i))
        cword(pj, i + 6)

        # for i in range(0x89d8, 0x8a20, 2):
        # 	data.Dataptr(pj, i, i + 2, pj.m.bu16(i))

    for i in range(0xE363, 0xE369, 2):
        x = cx.codeptr(pj, i)

    x = pj.add(0xB963, 0xB975, "tbl")
    for i in range(x.lo, x.hi):
        cbyte(pj, i)

    data.Data(pj, 0xCA73, 0xCA7C)

    data.Data(pj, 0xEC7C, 0xEC81)
    data.Data(pj, 0xEC81, 0xEC85)
    data.Data(pj, 0xEC85, 0xEC8B)
    data.Data(pj, 0xEC8B, 0xEC91)

    d_q(pj, 0xCB70)
    d_q(pj, 0xD4F5)
    d_q(pj, 0xD4F9)
    d_q(pj, 0xD4FD)
    d_q(pj, 0xD501)

    while pj.run():
        pass

    pj.set_label(0x6489, "CHAIN_PTR")

    pj.set_label(0xB800, "MEMCPY(X, Y, B)")
    pj.set_label(0xB80C, "SHR_Q")
    pj.set_label(0xB821, "SHL_Q")
    pj.set_label(0xB836, "COM_Q")
    pj.set_label(0xB846, "ADD_Q")
    pj.set_label(0xB86C, "SUB_Q")
    pj.set_label(0xB892, "MUL_Q")

    pj.set_label(0xEC91, "7SEG_XLAT(0x66a9)")
    pj.set_label(0xECAA, "7SEG_DIG(B)")

    pj.set_label(0xECD4, "DISPLAY(Y)")

    pj.set_label(0xF1A9, "DISPLAY_YES_NO(Y)")
    pj.set_label(0xF1B7, "IS_YES()")
    pj.set_label(0xF878, "PAUSE()")
    pj.set_label(0xFE5C, "Analog_Capture")
    pj.set_label(0xFE6E, "Capture_One_Analog")

    pj.set_label(0xF9, "ON_KEY")
Beispiel #9
0
def task(pj, cpu):
    ct = utils.cmd_tbl(pj, 0x7c64, 0x7c98)
    cta = utils.arg_range(pj, ct, 0x7d6c, 0x7d88)

    def ptr(pj, a):
        return data.Dataptr(pj, a, a + 2, pj.m.bu16(a))

    def cbyte(pj, a):
        c = data.Const(pj, a, a + 1)
        c.val = pj.m.rd(a)
        c.typ = ".BYTE"
        c.fmt = "0x%02x" % c.val

    ptr(pj, 0x6403)
    ptr(pj, 0x6405)
    ptr(pj, 0x6407)

    pj.set_label(0x7eed, "RAM_TEST_VALS")
    for a in range(0x7eed, 0x7ef9):
        cbyte(pj, a)

    c = ptr(pj, 0x7915)
    pj.set_label(c.lo, "@7SEGCODES")
    pj.set_label(c.dst, "7SEGCODES")
    c = seven_segment.table(pj, c.dst, c.dst + 0x10, verbose=False)

    pj.set_label(0x7ead, "ROM_LOCS")
    for a in range(0x7ead, 0x7ebf, 2):
        ptr(pj, a)

    # XXX: Add mising flow
    pj.todo(0x6845, cpu.disass)
    pj.todo(0x6867, cpu.disass)

    for i in range(0x6b23, 0x6b3b, 3):
        utils.data24(pj, i)

    for a in range(0x77d7, 0x77f7, 4):
        data.Txt(pj, a, a + 4)

    data.Txt(pj, 0x78f3, 0x78f7)
    data.Txt(pj, 0x78f7, 0x78fd)
    data.Txt(pj, 0x78fd, 0x78ff)

    utils.cmd_dispatch(pj, cpu, cta, 0x644c)

    pj.set_label(0x66ea, "ERR5_UNDEF_KEY")
    utils.key_dispatch(pj, cpu, 0x640c, 0x644c)

    utils.dsp_dispatch(pj, cpu, 0x6848, 0x6858)

    for i in (0x614c, 0x619c, 0x61a3, 0x69dd, 0x69e4):
        utils.float70(pj, i)

    c = cpu.codeptr(pj, 0x7909)
    pj.set_label(c.dst, "HPIB_CMD_PARSE")

    utils.square_tbl(pj)

    while pj.run():
        pass

    utils.apply_labels(pj, "B")
    utils.tramp(pj)
Beispiel #10
0
def task(pj, cpu):
	ct = utils.cmd_tbl(pj, 0x7c64, 0x7c98)
	cta = utils.arg_range(pj, ct, 0x7d6c, 0x7d88)

	def ptr(pj, a):
		return data.Dataptr(pj, a, a + 2, pj.m.bu16(a))

	def cbyte(pj, a):
		c = data.Const(pj, a, a + 1)
		c.val = pj.m.rd(a)
		c.typ = ".BYTE"
		c.fmt = "0x%02x" % c.val

	ptr(pj, 0x6403)
	ptr(pj, 0x6405)
	ptr(pj, 0x6407)

	pj.set_label(0x7eed, "RAM_TEST_VALS")
	for a in range(0x7eed, 0x7ef9):
		cbyte(pj,a)

	c = ptr(pj, 0x7915)
	pj.set_label(c.lo, "@7SEGCODES")
	pj.set_label(c.dst, "7SEGCODES")
	c = seven_segment.table(pj, c.dst, c.dst + 0x10, verbose=False)

	pj.set_label(0x7ead, "ROM_LOCS")
	for a in range(0x7ead, 0x7ebf, 2):
		ptr(pj, a)

	# XXX: Add mising flow
	pj.todo(0x6845, cpu.disass)
	pj.todo(0x6867, cpu.disass)

	for i in range(0x6b23, 0x6b3b, 3):
		utils.data24(pj, i)

	for a in range(0x77d7, 0x77f7, 4):
		data.Txt(pj, a, a + 4)

	data.Txt(pj, 0x78f3, 0x78f7)
	data.Txt(pj, 0x78f7, 0x78fd)
	data.Txt(pj, 0x78fd, 0x78ff)

	utils.cmd_dispatch(pj, cpu, cta, 0x644c)

	pj.set_label(0x66ea, "ERR5_UNDEF_KEY")
	utils.key_dispatch(pj, cpu, 0x640c, 0x644c)

	utils.dsp_dispatch(pj, cpu, 0x6848, 0x6858)

	for i in (0x614c, 0x619c, 0x61a3, 0x69dd, 0x69e4):
		utils.float70(pj, i)

	c = cpu.codeptr(pj, 0x7909)
	pj.set_label(c.dst, "HPIB_CMD_PARSE")

	utils.square_tbl(pj)

	while pj.run():
		pass

	utils.apply_labels(pj, "B")
	utils.tramp(pj)