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,)
Exemple #2
0
def example():
    m = mem.Stackup((FILENAME, ), nextto=__file__)
    cx = mcs48.i8748()
    cx.m.map(m, 0)

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

    gpu = hp1345a.hp1345a()

    cx.vectors()

    l = []
    for a in range(0x122, 0x200, 2):
        l.append(cx.m.bu16(a))
        gpu.disass(a, cx.m)

    for a in range(0x222, 0x2c8, 2):
        l.append(cx.m.bu16(a))
        gpu.disass(a, cx.m)

    hp1345_render.svg(cx.m, 0x122, 0x2c8, l=l)

    for a in range(0x31e, 0x400, 2):
        gpu.disass(a, cx.m)
    hp1345_render.svg(cx.m, 0x31e, 0x400)

    return NAME, (cx.m, )
def example():
    m = mem.Stackup((FILENAME, ), nextto=__file__)
    m.name = "EPROM"

    cx = banked.BankedCPU(8, hp_nanoproc.hp_nanoproc)
    cx.add_ins(hp_nanoproc_pg_desc, hp_nanoproc_pg_ins)

    l = [m]
    for p in range(8):
        cx[p].m.map(m, 0x000, 0x7ff, offset=p * 0x800)
        l.append(cx[p].m)

    for i, j in common.SYMBOLS.items():
        pg = i >> 11
        off = i & 0x7ff
        cx[pg].m.set_label(off, j)

    cx[0].disass(0x000)
    cx[0].disass(0x0ff)

    jmptables(cx)

    pagejumps(cx)

    return NAME, l
Exemple #4
0
def example():

    m = mem.Stackup((FILENAME,), nextto=__file__)
    m2 = mem.WordMem(0, m.hi >> 1, bits=16)
    for a in range(m.lo, m.hi, 2):
       m2[a >> 1] = m.bu16(a)
    cx = hp_hybrid.hp_hybrid()
    cx.m.map(m2, 0x20, offset=0x20)
    cx.flow_check.append(fc_call)

    rom_checksum(cx.m)

    for a, b in SYMBOLS.items():
        if b[0] == '_':
            cx.m.set_label(a, b[1:])
            cx.disass(a)
        elif b[0] == '#':
            cx.m.set_label(a, b[1:])
            y = data.Data(cx.m, a, a + 1)
            y.rendered = ".CONST\t0x%04x" % cx.m[a]
        else:
            cx.m.set_label(a, b)

    pat4244024.appendix_b_1(cx, 0x3a49)
    pat4244024.appendix_b_2(cx, 0x3ac2)
    pat4244024.appendix_b_3(cx, 0x3ca5)
    pat4244024.appendix_b_4(cx, 0x3d2c)
    pat4244024.appendix_b_5(cx, 0x3d4b)
    pat4244024.appendix_b_7(cx, 0x3df0)
    pat4244024.appendix_b_8(cx, 0x3e02)
    pat4244024.appendix_b_9(cx, 0x3e13)
    pat4244024.appendix_b_10(cx, 0x3e30)
    pat4244024.appendix_b_11(cx, 0x3e4a)
    pat4244024.appendix_b_12(cx, 0x3e6c)
    pat4244024.appendix_b_13(cx, 0x3e78)
    pat4244024.appendix_b_15(cx, 0x3e86)
    pat4244024.appendix_b_16(cx, 0x3ebc)
    pat4244024.appendix_b_17(cx, 0x3ebf)
    pat4244024.appendix_b_18(cx, 0x3ec2)
    pat4244024.appendix_b_21(cx, 0x3a35)
    pat4244024.appendix_b_28a(cx, 0x0020)
    pat4244024.appendix_b_28b(cx, 0x0200)

    if True:
        for a in range(0x3ef, 0x40a):
            data.Const(cx.m, a, a + 1)
            y = wgstring(cx.m, cx.m[a])
            y.compact = True
        for a in range(0x1ebb, 0x1ec6):
            data.Const(cx.m, a, a + 1)
            y = wgstring(cx.m, cx.m[a])
            y.compact = True

    cx.disass(0x20)

    code.lcmt_flows(cx.m)

    return NAME, (cx.m,)
def example():
    cx = z80.z80()
    m = mem.Stackup(files=(FILENAME, ), nextto=__file__)
    cx.m.map(m, 0, 0x12)
    cx.m.map(m, lo=0xa000, hi=0xa59a, offset=0x12)

    data.Txt(cx.m, 0xa533, label=False)
    data.Txt(cx.m, 0xa546, label=False)
    data.Txt(cx.m, 0xa571, label=False)
    data.Txt(cx.m, 0xa574, label=False)
    data.Txt(cx.m, 0xa588, 0xa58c, label=False)
    data.Txt(cx.m, 0xa58c, 0xa590, label=False)
    data.Txt(cx.m, 0xa593, 0xa593 + 0x7, label=False)

    cx.disass(0x0000)

    # Interrupt vector table
    for a in range(12):
        cx.codeptr(0xa000 + a * 2)

    return NAME, (cx.m, )
Exemple #6
0
def example():
    m = mem.Stackup(
        files=((FILENAME, )),
        nextto=__file__,
    )

    s = chargen.SVG_Charset(
        "/tmp/cbm900_lowres.svg",
        cols=16,
        char_w=7,
        char_h=13,
        imargin=1,
        linewidth=1,
    )
    for i in range(256):
        l = []
        for j in range(13):
            l.append(m[i * 16 + j])
        s.set_char(i // 16, i % 16, l)
    s.render()
    return NAME, (m, )
Exemple #7
0
def example():
    cx = mc6800.mc68hc11()
    cx.m.map(mem.Stackup((FILENAME, ), nextto=__file__), 0x8000)

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

    cx.register_labels()

    cx.flow_check.append(post_arg_func)
    cx.flow_check.append(bogo_flow)

    leds(cx.m)
    chain_table(cx.m)
    asf_table(cx.m)
    onkey_table(cx)
    cmd_table(cx)
    fn_table(cx)
    chaindata_table(cx.m)
    misc_stuff(cx)

    cx.vectors()

    return NAME, (cx.m, )
def example():
    m0 = mem.Stackup(
        files=(("EPROM_C_900_boot-L_V_1.0.bin",
                "EPROM_C_900_boot-H_V_1.0.bin"), ),
        nextto=__file__,
    )

    cx = z8000.z8001()
    cx.m.map(m0, 0x00000000, 0x00006800)
    cx.m.map(m0, 0x01000000, 0x01001016, 0x00006800)
    cx.m.map(m0, 0x00007816, 0x00010000, 0x00007816)

    cx.flow_check.append(fc_outstr)
    cx.z8010_mmu(0xf8)
    cx.z8010_mmu(0xfc)

    for i, j in LABELS.items():
        cx.m.set_label(i, j)

    cx.m.set_block_comment(0x6800, "0x6800-0x7816 mapped to segment 0x1:0x0")

    # const.w32(p, 0x01000614)
    # cx.m.set_label(0x01000614, "screen_ptr")
    #cx.m.set_label(0x01001800, "is_lores")
    #cx.m.set_label(0x010017ff, "is_hires")
    #cx.m.set_label(0x01001562, "input_buffer")
    #cx.m.set_label(0x01001562, "input_buffer")

    if True:
        cx.vectors()

    if True:
        for v, a in (
            (
                "VEC0",
                0x0008,
            ),
            (
                "VEC1",
                0x0010,
            ),
            (
                "VEC2",
                0x0018,
            ),
            (
                "VEC3",
                0x0020,
            ),
            (
                "VEC4",
                0x0028,
            ),
            (
                "VEC5",
                0x0030,
            ),
        ):
            b = cx.vector(a, v)

    if True:
        switch(cx, 0x69e, 0xa)
        switch(cx, 0x31c4, 0x4)
        switch(cx, 0x39ba, 0x10)

    if True:
        for a in range(0x419e, 0x4202, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_%x" % a)

        cx.disass(0x20bc)
        cx.disass(0x3ec6)

        cx.disass(0x06da)
        cx.disass(0x0214)
        cx.disass(0x10ec)
        cx.disass(0x11a6)
        cx.disass(0x2028)
        cx.disass(0x2034)
        cx.disass(0x3bd2)

        for a in (
                0x01c0,
                0x0c0a,
                0x0c44,
                0x0e9e,
                0x0ee0,
                0x0eae,
                0x0ef0,
        ):
            cx.m.set_line_comment(a, "CALL_RR10_%x" % a)
            cx.disass(a)

        for a in range(0x3e90, 0x3ea0, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_%x" % a)

        chargendata(cx.m, 0x45fe + 0)

        for a, b, c in (
            (0x01000006, 0x0100000e, 4),
            (0x0100003e, 0x01000076, 14),
            (0x01000010, 0x0100003c, 4),
            (0x01000618, 0x01000658, 4),
            (0x01000766, 0x010007ae, 4),
            (0x010007b4, 0x010007c4, 4),
            (0x01000c1a, 0x01000c26, 4),
        ):
            while a < b:
                y1 = cx.dataptr(a)
                y2 = data.Txt(cx.m, y1.dst, align=1, label=False)
                cx.m.set_line_comment(y1.lo, '"' + y2.txt + '"')
                a += c

        for a in range(0x0100065a, 0x01000708, 6):
            data.Txt(cx.m, a, label=False, align=2)

        for a in range(0x01000c26, 0x01000e19, 6):
            y1 = data.Pstruct(cx.m, a, ">HHH")

        data.Txt(cx.m, 0x0c75, align=1, label=False)
        data.Txt(cx.m, 0x0cb1, align=1, label=False)
        for a in range(0xc4a, 0xc74, 2):
            data.Pstruct(cx.m, a, "BB")

        hd6845_tab(cx.m)

    return NAME, (cx.m, )
def example():
    m = mem.Stackup((FILENAME, ), nextto=__file__)
    cx = mos6500.mos6500()
    cx.m.map(m, 0xe000)

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

    for i in range(7):
        data.Const(cx.m, 0xe28a + i, 0xe28a + i + 1)

    a = 0xe7bf
    for i in range(5):
        y = data.Pstruct(cx.m, a, "<4B")
        a = y.hi

    y = data.Pstruct(cx.m, 0xe80a, "<4B")

    a = 0xe675
    y = data.Pstruct(cx.m, a, "<4B")
    a = y.hi
    y = data.Pstruct(cx.m, a, "<4B")

    a = 0xe962
    y = data.Pstruct(cx.m, a, "<5B")
    a = 0xe967
    y = data.Pstruct(cx.m, a, "<B")
    a = 0xe968
    y = data.Pstruct(cx.m, a, "<5B")

    a = 0xff9c
    y = data.Pstruct(cx.m, a, "<HH")

    cx.vectors()

    for i in range(6):
        cx.codeptr(0xe291 + 2 * i)

    for a in (
            0xe034,
            0xe906,
            0xe90c,
            0xe948,
            0xe96d,
            0xe972,
            0xe977,
            0xe989,
            0xe98e,
            0xe993,
            0xea33,
            0xea36,
            0xea39,
            0xea9c,
            0xeab1,
            0xff93,
            0xff96,
            0xff99,
            0xfff3,
            0xfff6,
            0xfff9,
    ):
        cx.disass(a)
        cx.m.set_line_comment(a, "MANUAL")

    return NAME, (cx.m, )
Exemple #10
0
def example():
    m = mem.Stackup((FILENAME, ), nextto=__file__)
    cx = i8086.i8086()
    cx.has_8087()
    cx.m.map(m, 0xe0000)

    cx.disass(0xffff0)

    def vect(seg, off):
        a = (seg << 4) + off
        # print("VECTOR %05x" % a)
        cx.disass(a)
        cx.m.set_label(a, "VECTOR")

    # Vectors initialized at 0xe21b2...
    vect(0xe000, 0x1e67)
    vect(0xe1f5, 0x35e9)
    vect(0xe737, 0x1fdf)
    vect(0xf8bd, 0x417b)

    #######################################################################
    # Random guesses

    if False:
        cx.disass(0xe63cf)
        cx.disass(0xe7bd7)
        cx.disass(0xe7fdd)
        cx.disass(0xe834c)
        cx.disass(0xe9251)
        cx.disass(0xfcd68)
        cx.disass(0xffb56)

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

    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)

    txl(0xff1b, 0xffe00)
    txl(0xff1b, 0xffe22)
    txl(0xff1b, 0xffe44)
    txl(0xff1b, 0xffe66)
    txl(0xff1b, 0xffe88)
    txl(0xff1b, 0xffeaa)

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

    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)

    def tbl2(a):
        assert cx.m[a + 0] == 0x2e
        assert cx.m[a + 1] == 0xff
        assert cx.m[a + 2] == 0xa7
        o = cx.m.lu16(a + 3)
        s = (a + 5 - o)
        #print("T2", "seg", "%05x" % s, "off", "%04x" % o)
        e = o + s
        l = 0xfffff
        while e < l:
            n = cx.m.lu16(e)
            if s + n < l:
                l = s + n
            # print("e %05x" % e, "l %05x" % l, "n %04x -> %05x" % (n, s + n))
            e += 2
        tbl(s >> 4, o + s, e)

    t2dict = {}

    more = True

    while more:
        more = False
        for i in cx.m:
            if i.tag != "i8086":
                continue
            if i.lo in t2dict:
                continue
            if cx.m[i.lo + 0] != 0x2e:
                continue
            if cx.m[i.lo + 1] != 0xff:
                continue
            if cx.m[i.lo + 2] != 0xa7:
                continue
            t2dict[i.lo] = True
            tbl2(i.lo)
            more = True

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

    more = False
    while more:
        more = False
        for lo, hi in cx.m.gaps():
            if lo + 1 == hi:
                continue
            if cx.m[lo] == 0x55:
                print("%04x, %04x" % (lo, hi))
                cx.disass(lo)
                more = True
            elif cx.m[lo] == 0x00 and cx.m[lo + 1] == 0x55:
                print("%04x, %04x" % (lo, hi))
                cx.disass(lo + 1)
                more = True

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

    def text_lines(cx, a):
        # cx.m.set_line_comment(a, "txt-tbl")
        cx.m.add_range(a, a + 24, txt="text-tbl")
        data.Txt(cx.m, a, a + 8, label=False)
        data.Txt(cx.m, a + 8, a + 16, label=False)
        data.Txt(cx.m, a + 16, a + 24, label=False)

    text_lines(cx, 0xe57e0 + 0x1f0)
    text_lines(cx, 0xe57e0 + 0x208)
    text_lines(cx, 0xe57e0 + 0x220)

    text_lines(cx, 0xe68d0)
    text_lines(cx, 0xe68e8)
    text_lines(cx, 0xe6900)

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

    return NAME, (cx.m, )
Exemple #11
0
def example():

    cx = hp_nanoproc.hp_nanoproc_pg()
    cx.m.map(mem.Stackup((FILENAME, ), nextto=__file__), 0)

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

    cx.disass(0)
    cx.disass(0xf7)
    cx.disass(0xfd)
    cx.disass(0xff)

    cx.m.set_block_comment(
        0x000, """HP 3455A inguard ROM

The nanoprocessor takes two clocks per instruction.
The clock runs at 819.2 kHz if 50Hz line frequency is selected
and 983.04 kHz for 60Hz line frequency.

The internal power line cycle counter is 256 times a 32 instruction loop
per PLC, i.e. 256*32*2/983040 giving 16.67 ms for 60Hz.

The startup code is at 0x0FD

DEV1 bits:        REG3 bits:
0x20    LNRF      0   Autocal LNRF and HPRF only
0x10    HPRF      1   8 PLC
0x08    HAZ       2   Autocal - no input to AtoD
0x04    HPRS      3
0x02    LNRS      4   Set device latches to values from outguard
0x01    LVIN      5
Note all device output is inverted in hardware, so the complement must be written to DEV1
""")
    cx.m.set_block_comment(
        0x03C, """AtoD Auto-Zero
0x14 = HAZ on, everything else off
AUTOZERO_LOOP is 16 instructions per iteration
""")
    cx.m.set_block_comment(
        0x05A, """Main Integration Loop

Register usage:
REG0            # PLCs
REG2            AtoD autocal counter
REG3            Control bits from Outguard
REG5            AtoD device bits for discharge during integration
REG7            Discharge during integration counter
REG9:REG8        PLC counter (REG9 has PLCs elapsed)
REG15            AtoD device bits
REG13:REG12:REG11    Count

These device control bits are used as temporary flags.  It is assumed that
the outguard doesn't drive them and doesn't look at them during integration.

DCTL0    Tentative sign of result is valid
DCTL3    Tentative sign of result

DCTL3 is set during integration when the count is zero.  Should the input voltage
change such that the sign of the voltage on the integration capacitor changes
and the magnitude is greater than 10V, then DCTL0 is cleared to indicate the
sign is potentially invalid and the count should be decremented during the current
discharge period.  Given the approximately 80 times multiplication factor between input
voltage and voltage on the integration capacitor, it wouldn't require much reverse
voltage for very long for this to happen.

DEV1 is written by the second instruction of each loop/sub-loop.
(This fact is used by the PLC counter.)
Each loop or sub-loop during integration is exactly 32 instructions
The count is shifted left by 3 after integration
During fast rundown, each loop is exactly 4 instructions and
during slow rundown, each loop is exactly 2 instructions
REG11 is set during slow rundown, REG13:REG12 are used during integration and fast rundown
The doubling of the count rate and inherent 8 bit shift give the 128:1 weighting between
fast and slow rundown.
""")
    cx.m.set_block_comment(
        0x60, """Select discharge type

This code assumes that if DCTL0 (0DETECT) is zero, then DCTL2 is set.
The instruction counts and control bits in REG5 will be wrong otherwise.
DCTL2 was initialized to 1 and does not appear to change during the integration phase.
""")
    cx.m.set_block_comment(
        0x8B, """Start discharge during integration

The loop initialization code assumes that there will be no overflow of REG12
when it increments it.  This is usually true since this loop will increment
the count by 8 each time it runs, so we won't hit a count of 255 here.
However, if the input sign changes, with the count at a multiple of 256,
we will decrement the counter and miss the underflow!
REG12 overflow IS handled in the loop itself.
This loop runs for (8 * 32 * 2) clock periods or about 0.5ms.  This will reduce
the magnitude of voltage on the integration capacitor by about 6.1V (1mA from a 0.082uF
capacitor for 0.5ms).

Note that the 0V detect signal was used to set up REG5 and is also used in
CHECK_RESULT_SIGN to determine whether we will increment of decrement the count.
Since we are over 10V here, there is no chance it changed inbetween.
""")
    cx.m.set_block_comment(
        0xFF, """Interrupt Handler

The interrupt breaks the slow rundown loop which was accumulating the count in A.
The slow rundown count is saved in REG11 and added to/subtracted from the
rest of the count in REG13:REG12.
The rundown is stopped and auto-zero started immediately.
""")
    cx.m.set_block_comment(
        0x14A, """Stop integrating the input and start the rundown

First, counts accumulated during the integration phase are multiplied by 8.
This is because each count represented 32 instruction periods and in the fast
rundown phase, each count represents 4 instruction periods.
It's possible the rundown during integration overshot 0V, so the counts here
may need subtracting from the count, hence the two loops, one that increments
and one that decrements.
""")
    cx.m.set_block_comment(
        0x19B, """Slow Rundown

In the slow rundown, counts represent 2 instruction periods.  This, along with the
fact that the current count is effectively shifted left by 8 bits when the slow
count is concatenated gives the 128:1 weighting.
Again, the fast rundown might have overshot 0V, so the direction of the rundown
must be set accordingly.  The interrupt is armed to fire when 0VDETECT changes -
It's the only way you can increment a counter and conditionally loop with two instructions
(it took four instructions per iteration during the fast rundown).
""")
    cx.m.set_block_comment(
        0x1CB, """Increment the PLC Counter

This is called every 32 instructions during integration, hence every 64 clocks.
(256 * 64 * clock period) is one PLC, so the high byte of the counter (REG9) ends
up with the number of PLCs elapsed since the counter was zeroed.
REG9 is returned in the accumulator.
""")

    cx.m.set_line_comment(0x004, "Use existing settings\n")
    cx.m.set_line_comment(0x006, "Default Control Bits\n")
    cx.m.set_line_comment(0x009, "Use default settings\n")
    cx.m.set_line_comment(0x01D, "Calculated parity\n")
    cx.m.set_line_comment(0x03C, "HAZ on\n")
    cx.m.set_line_comment(
        0x03E, "1..11 instructions; loop is 16 instr. per iteration\n")
    cx.m.set_line_comment(0x046, "Initialize (zero) the count\n")
    cx.m.set_line_comment(0x04C, "LVIN on\n")
    cx.m.set_line_comment(0x055, "LNRF,HPRF on\n")
    cx.m.set_line_comment(0x075, "LNRF,HPRF on\n")
    cx.m.set_line_comment(0x058, "All AtoD inputs off\n")
    cx.m.set_line_comment(0x078, "All AtoD inputs off\n")
    cx.m.set_line_comment(0x062, "HPRF\n")
    cx.m.set_line_comment(0x064, "LNRF\n")
    cx.m.set_line_comment(0x06A, "REG7 = 7\n")
    cx.m.set_line_comment(0x088, "Maintain 32 instr. between writes to DEV1\n")
    cx.m.set_line_comment(0x09E, "Inc/dec count as appropriate\n")
    cx.m.set_line_comment(0x0FF, "Stops rundown and sets HAZ\n")
    cx.m.set_line_comment(0x132, "Result is negative\n")
    cx.m.set_line_comment(0x14A, "Set Integrator to 'Hold'\n")
    cx.m.set_line_comment(0x16C, "LNRF on\n")
    cx.m.set_line_comment(0x173, "Set Integrator to 'Hold'\n")
    cx.m.set_line_comment(0x177, "HPRF on\n")
    cx.m.set_line_comment(0x17B, "HPRF on\n")
    cx.m.set_line_comment(0x182, "LNRF on\n")
    cx.m.set_line_comment(0x189, "Set Integrator to 'Hold'\n")
    cx.m.set_line_comment(0x19B, "Arm interrupt on 0VDETECT change\n")
    cx.m.set_line_comment(0x1A1, "HPRS on\n")
    cx.m.set_line_comment(0x1A5, "LNRS on\n")
    cx.m.set_line_comment(0x1A8, "Loop is broken by interrupt\n")
    cx.m.set_line_comment(0x1B4, "Result so far is positive\n")
    #line_comment(0x1B4, "Result so far is negative\n")

    return NAME, (cx.m, )
Exemple #12
0
def example():
    m = mem.Stackup((
        ("85680-80115.BIN", "85680-80116.BIN"),
        ("85680-80113.BIN", "85680-80114.BIN"),
    ),
                    nextto=__file__)

    # Checum EPROMS
    # See 00e9e/ROMSUM
    s = [0xff, 0xff, 0xff, 0xff]
    for a in range(32768):
        s[0] += m[a * 2]
        s[1] += m[a * 2 + 1]
        s[2] += m[a * 2 + 65536]
        s[3] += m[a * 2 + 65536 + 1]
    for i in s:
        assert i & 0xff == 0

    cx = mycpu()
    cx.m.map(m, 0)
    cx.macro("DISPLAY_READY()", "0838 0007 c0e1 66f8")
    cx.flow_check.append(flow_post_arg)

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

    # Where ?
    # y = data.Const(cx.m, 0xfffe, 0x10000)
    # cx.m.set_label(y.lo, "eprom_lo_chksum")
    y = data.Const(cx.m, 0x19854, 0x19856)
    cx.m.set_label(y.lo, "eprom_hi_chksum")

    for i in post_arg:
        j = post_arg[i]
        if j and j[0] != "":
            cx.m.set_label(i, j[0])

    if True:
        for b, e in (
            (0x06936, 0x0693a),
            (0x06a2c, 0x06b84),
            (0x070ca, 0x070d6),
            (0x081ae, 0x081ba),
            (0x1357a, 0x1358a),
            (0x13e58, 0x13e70),
            (0x14960, 0x1497c),
            (0x14c94, 0x14cb4),
            (0x14f98, 0x14fa8),
            (0x15094, 0x150a4),
            (0x15140, 0x15150),
            (0x15e0e, 0x15e32),
            (0x172b8, 0x172c4),
            (0x17dbe, 0x17dce),
        ):
            for a in range(b, e, 4):
                x = cx.m.bu32(a)
                data.Dataptr(cx.m, a, a + 4, x)
                if not cx.m.occupied(x):
                    data.Txt(cx.m, x, pfx=1, align=2)

        data.Txt(cx.m, 0x15dfc, pfx=1, align=2)

    cx.flow_check.append(flow_switch)

    cx.vectors(hi=0xc0)

    if True:
        n = 0
        for a in range(0x193da, 0x194b2, 2):
            y = oldcmd(cx.m, a, n)
            n += 1
        # print("OLDCMDS %d" % ((0x194b2-0x193da)/2))

        for a in range(0x194b2, 0x1951e, 8):
            y = data.Const(cx.m, a, min(a + 8, 0x1951e), fmt="0x%02x")
        # print("KEYTAB %d" % ((0x1951e-0x194b2)/1))

        for a in range(0x1951e, 0x1952c, 8):
            y = data.Const(cx.m, a, min(a + 8, 0x1952c), fmt="0x%02x")
        # print("IMEDBITS %d" % ((0x1952c-0x1951e)/1))

        for a in range(0x1952c, 0x195c4, 16):
            y = data.Const(cx.m, a, min(a + 16, 0x195c4), "0x%08x", cx.m.bu32,
                           4)
        # print("SFLGVAL %d" % ((0x195c4-0x1952c)/2))

    if True:
        a = 0x193a0
        while a > 0x18c3a:
            y = mnem(cx, a)
            x = cx.m.bu16(y.lo - 2)
            a = y.lo

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

    switches[0x09ae8] = {}
    switches[0x09d78] = {}
    switches[0x0a5de] = {}
    switches[0x0af5c] = {}
    switches[0x0b5ec] = {}
    switches[0x0bb4e] = {}
    switches[0x0bd5a] = {}
    switches[0x0bd6e] = {
        0: "KEYS_00_1f",
        1: "KEYS_20_3f",
        2: "KEYS_40_5f",
        3: "KEYS_60_7f",
        4: "KEYS_80_9f",
        5: "KEYS_a0_bf",
    }

    for n in KEYNOS:
        t = KEYNOS[n]
        # print("KEY_%02x" % n, t)
        sk = "KS%c" % n
        ksk = hp856x_cmds.cmds.get(sk)
        if ksk is not None and type(ksk) != str:
            ksk = ksk[1]
        if ksk is None:
            ksk = "==" + t
        if n < 0x20:
            switches[0x9ae8][n] = "KEY_%02x_" % n + t
        if n >= 0x20 and n < 0x30:
            switches[0x9d78][n - 0x20] = "KEY_%02x_" % n + t
        if n >= 0x40 and n < 0x60:
            switches[0xa5de][n - 0x41] = "KEY_%02x_" % n + t
            switches[0xaf5c][n - 0x41] = "KEY_S%02x_KS%c_" % (n, n) + ksk
        if n >= 0x60 and n < 0x80:
            switches[0xb5ec][n - 0x61] = "KEY_%02x_" % n + t
            switches[0xbb4e][n - 0x60] = "KEY_S%02x_KS%c_" % (n, n) + ksk
        if n >= 0xa0 and n <= 0xbf:
            switches[0xbd5a][n - 0xa0] = "KEY_%02x_" % n + t

    if True:
        for b, e in (
            (0x0e750, 0x0e778),
            (0x15ca4, 0x15cb4),
        ):
            for a in range(b, e, 8):
                data_double(cx.m, a)

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

    if True:

        cx.disass(0x2f38)

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

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

        for a in (
                0x0e2fa,
                0x0e308,
                0x0e318,
                0x12986,
                0x12988,
                0x1298c,
                0x12990,
                0x1694e,
                0x16954,
        ):
            y = data.Txt(cx.m, a, pfx=1, align=2)

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

        data.Dataptr(cx.m, 0xe39a, 0xe39a + 4, cx.m.bu32(0xe39a))

        data.Const(cx.m, 0x2140, 0x2148, "%d", cx.m.bu64, 8)
        data.Const(cx.m, 0x2148, 0x214c, "%d", cx.m.bu32, 4)

        for a in (
                0x0645e,
                0x06476,
                0x0647e,
                0x0648a,
                0x06492,
                0x0649a,
                0x064a6,
                0x064be,
                0x0e2c4,
                0x0e2d4,
                0x0e2cc,
                0x0e32a,
                0x0e332,
                0x0e37c,
                0x0e384,
                0x128ca,
                0x15da0,
        ):
            if not cx.m.occupied(a):
                y = data_bcd(cx.m, a)
                cx.m.set_label(a, "BCD_%x" % y.data[0])

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

        for a in range(0x693c, 0x6a2c, 6):
            data.Const(cx.m, a, a + 6, "0x%04x", cx.m.bu16, 2)

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

        a = 0x6b84

        dsp = hp85662a.hp85662a()
        while a < 0x6c98:
            x = cx.m.bs16(a)
            if x < 0:
                y = data.Data(cx.m, a, a + 2)
                y.fmt = ".DSPLOC\t0x%04x" % -x
                y.lcmt = "adr=%d" % -x
                dsp = hp85662a.hp85662a()
            else:
                y = dsp.disass(a, cx.m)
            a = y.hi

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

        for a in range(0x0e3be, 0x0e3d4, 2):
            data.Txt(cx.m, a, a + 2, label=False)

        #######################################################
        # 0ee98  00 01 93 be
        # 0eeaa  00 01 93 da  |    |
        # 0ee8e  00 01 da ee  |    |
        #######################################################
        # Orphans ?

        if False:
            cx.disass(0x01b88)
            cx.disass(0x01b8e)
            cx.disass(0x01b94)
            cx.disass(0x01b9a)
            cx.disass(0x01b9e)
            cx.disass(0x01ba2)
            cx.disass(0x01ba8)
            cx.disass(0x01c76)
            cx.disass(0x01c82)
            cx.disass(0x01c90)
            cx.disass(0x01cd2)
            cx.disass(0x01d14)

            cx.disass(0x01578)
            cx.disass(0x01594)
            cx.disass(0x0171a)
            cx.disass(0x01906)
            cx.disass(0x02dee)
            cx.disass(0x02df4)
            cx.disass(0x03412)
            cx.disass(0x11e74)

        # from 0x2272
        cx.disass(0x2282)

        # filled in 0xffffabd2
        cx.disass(0x0ed98)

        cx.disass(0x0df5e)  # Arg to 0x802
        cx.disass(0x3292)  # 0x3284

        #######################################################
        # pat 4,244,024 pg 262 lin 3700

        for a in range(0x4fac, 0x4fec, 2):
            y = data.Const(cx.m, a, a + 2, "0x%04x", cx.m.bu16, 2)

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

        y = data.Const(cx.m, 0x193a2, 0x193be, "%d", cx.m.bu16, 2)
        cx.m.set_label(y.lo, "HASHPTR2")
        y = data.Const(cx.m, 0x193be, 0x193da, "%d", cx.m.bu16, 2)
        cx.m.set_label(y.lo, "HASHPTR")

        #######################################################
        for a in range(0x19826, 0x19853, 1):
            y = data.Const(cx.m, a, a + 1, fmt="0x%02x")

    else:
        y = cx.disass(0xda1e)

        for i in y.__dict__:
            print("\t", i, y.__dict__[i])

    for i in cx.m:
        if i.tag != "m68000":
            continue
        if i.dstadr in (0x940c, 0xed54):
            y = list(cx.m.find(hi=i.lo))
            if len(y) != 1:
                continue
            y = y[0]
            if cx.m[y.lo] == 0x70:
                k = cx.m[y.lo + 1]
            elif cx.m.bu16(y.lo) == 0x103c:
                k = cx.m.bu16(y.lo + 2)
            else:
                continue
            if not k in KEYNOS:
                continue
            y.oper[0].txt = "#KEY_" + KEYNOS[k]

        if i.dstadr in (0xe4e8, ):
            y = list(cx.m.find(hi=i.lo))
            if len(y) != 1:
                continue
            y = y[0]
            if y.mne != "PEA.L":
                continue
            z = data.Txt(cx.m, y.dstadr, pfx=1, align=2)
            y.lcmt = "'" + z.txt + "'"
        if i.dstadr in (0xe718, 0x3456, 0x6ce0):
            y = list(cx.m.find(hi=i.lo))
            if len(y) != 1:
                continue
            y = y[0]
            if cx.m.bu16(y.lo) != 0x203c:
                continue
            a = cx.m.bu32(y.lo + 2)
            z = data.Txt(cx.m, a, pfx=1, align=2)
            y.lcmt = "'" + z.txt + "'"
            if i.dstadr == 0xe718:
                w = list(cx.m.find(hi=y.lo))
                if len(w) != 1:
                    continue
                w = w[0]
                if w.mne != "PEA.L":
                    continue
                z = list(cx.m.find(w.dstadr))
                if not z:
                    z = [data.Txt(cx.m, w.dstadr, pfx=1, align=2)]
                w.lcmt = "'" + z[0].txt + "'"

    y = data.Const(cx.m, 0x693a, 0x693c, "%d", cx.m.bu16, 2)

    y = data.Const(cx.m, 0x00e9a, 0x00e9e, "%d", cx.m.bu32, 4)
    y = data.Const(cx.m, 0x00ef2, 0x00efe, "0x%08x", cx.m.bu32, 4)

    #cx.m.set_label(0x18d24, "MNEM")
    #cx.m.set_label(0x195c4, "PARMTYPE")
    #cx.m.set_label(0x196b6, "PRCADRS")

    # 0xffff0005
    # 0xffff0007
    # 0xffff0009
    # 0xffff0013
    # 0xffff0019
    # 0xffff0021
    # 0xffff0027
    # 0xffff0035

    #cx.m.set_label(0xffff4000, "PIT_PGCR")
    #cx.m.set_label(0xffff4002, "PIT_PSRR")
    #cx.m.set_label(0xffff4004, "PIT_PADDR")
    #cx.m.set_label(0xffff4006, "PIT_PBDDR")
    #cx.m.set_label(0xffff4008, "PIT_PCDDR")

    #cx.m.set_label(0xffff4010, "PIT_PADR")
    #cx.m.set_label(0xffff4012, "PIT_PBDR")

    # 0xffff8000

    # 0xffffa6ae = stack

    # I/O Decoding on A15
    #####################
    # 0x...00 BIO - BOTTOM/RF
    # 0x...20 DBCLK      #2
    # 0x...40 TIO - TOP/IF
    # 0x...64 LDBTEST    #7
    # 0x...80 LHPIB
    # 0x...a4 LDBTEST    #7
    # 0x...c0 LBUS
    # 0x...e0 HPIBSW     #1
    # 0x...e4 LATR       #5

    # HPIB
    ######
    # 0xffffc081
    # 0xffffc083
    # 0xffffc085
    # 0xffffc087
    # 0xffffc089
    # 0xffffc08b
    # 0xffffc08d
    # 0xffffc08f

    # LBUS
    ######

    # 0xffffc0e0 ?

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

    if False:
        for a in (
                0x01298,
                0x013a8,
                0x013d8,
                0x013de,
                0x013e4,
                0x01e12,
                0x01e94,
                0x0217e,
                0x0218c,
                0x02194,
                0x021a8,
                0x02268,
        ):
            # print("ORPHAN %x" % a)
            y = cx.disass(a)
            y.lcmt = "ORPHAN - "

        nondisc = {
            0x14ce: 0,
        }

        while True:
            l = []
            for b, e in cx.m.gaps():
                if b in nondisc:
                    continue
                if e - b < 2:
                    continue
                if cx.m.bu16(b) in (0x4eb8, 0x4e56):
                    l.append(b)
                elif cx.m[b] in (0x61, ):
                    l.append(b)
            # print(l)
            for i in l:
                y = cx.disass(i)
                y.lcmt = "DISCOVER - "
            if l:
                break

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

    return NAME, (cx.m, )
Exemple #13
0
def example():
    m = mem.Stackup((FILENAME,), nextto=__file__)

    cx = hp_nanoproc.hp_nanoproc_pg()
    cx.m.map(m, 0)

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

    cx.disass(0)
    cx.disass(0xff)

    #######################################################################
    if True:
        for a0 in range(4, 0x20, 4):
            assert cx.m[a0] == 0xc8
            pg = (cx.m[a0 + 1] & 0x07) << 11
            assert pg == a0 << 9
            dpf = cx.m[a0 + 2] << 8
            dpf |= cx.m[a0 + 3]
            dpf &= 0x7ff
            dpf |= pg
            cx.m.set_label(dpf, "DISP_%d" % (a0 >> 2))
            cx.disass(a0)
            cx.disass(dpf)
            for a1 in range(pg, dpf, 2):
                da = cx.m[a1] << 8
                da |= cx.m[a1 + 1]
                da &= 0x7ff
                da |= pg
                v = a0 << 3
                v |= (a1 - pg) >> 1
                cx.m.set_label(a1, "PTR_%02x" % v)
                cx.m.set_label(da, "FN_%02x" % v)
                cx.disass(a1)

    #######################################################################
    def jmp_table(lo, hi, span, txt="table"):
        cx.m.set_block_comment(lo, txt)
        for a in range(lo, hi, span):
            cx.disass(a)

    #######################################################################
    if True:
        # Comes from 0x0d01
        # returns to 0xd02
        jmp_table(0x0f80, 0x0fa8, 4, "LED Segment Table")

    #######################################################################
    if True:
        # Comes from 0xab2
        # does not return
        jmp_table(0x0fa8, 0x0fc0, 2)

    #######################################################################
    if True:
        # Comes from 0xb3b
        # returns to 0xb3c
        jmp_table(0x0fc0, 0x0fe0, 4)

    #######################################################################
    if True:
        # Comes from 0xb62
        # returns to 0xb63
        jmp_table(0x0fe0, 0x1000, 4)

    #######################################################################
    if True:
        # Comes from 0x1aa0
        # returns to 1aa1
        jmp_table(0x1840, 0x1878, 8)

    #######################################################################
    if True:
        # Comes from 0x29f9
        # returns to 29fa
        jmp_table(0x2fb8, 0x3000, 8)

    #######################################################################
    if True:
        # Comes from 0x3c37
        # does RET
        jmp_table(0x3fd8, 0x4000, 4)

    return NAME, (m,)
def example():
    m = mem.Stackup((FILENAME,), nextto=__file__)
    cx = mcs51.I8032()
    cx.m.map(m, 0)

    cx.disass(0xb)
    cx.vectors(which=("RESET", "TF0"))

    cx.disass(0x600)

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

    for a, b in BIT_SYMBOLS.items():
        cx.as_bit.set_label(a, b)

    for a, b in DATA_SYMBOLS.items():
        cx.as_data.set_label(a, b)

    cx.m.set_line_comment(0xa31, "Mask Left/Right Buttons")
    cx.m.set_line_comment(0xa47, "Mask Left/Right Buttons")
    cx.m.set_line_comment(0xa67, "Mask Dials")

    for i in range(0, 0x18, 8):
        data.Txt(cx.m, 0x0a2 + i, 0x0a2 + i + 0x08, label=False)

    for i in range(0, 0x18, 8):
        data.Txt(cx.m, 0x78a + i, 0x78a + i + 0x08, label=False)


    #######################################################################
    def cmd_func(a1, a2, n):
        cx.m.set_label(a1, "DO_CMD%d" % n)
        a = a2
        while True:
            if cx.m[a] != 0xb4:
                break
            c = cx.m[a + 1]
            d = cx.m[a + 2]
            cx.m.set_label(a, "CMD%d_%02x" % (n, c))
            a += 3 + d


    cmd_func(0xbf3, 0xbf7, 1)
    cmd_func(0x823, 0x827, 2)
    cmd_func(0x84f, 0x851, 3)
    #######################################################################

    #######################################################################
    for a in range(0xba, 0x100, 2):
        x = data.Const(cx.m, a, a + 2)
        x.typ = ".WORD"
        x.val = cx.m.lu16(a)
        x.fmt = "0x%04x" % x.val

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

    x = data.Data(cx.m, 0x100, 0x600, "chargen")
    x.rendered = "*CHARGEN*"
    x.compact = True

    cs = chargen.SVG_Charset(
        fn="/tmp/" + NAME + "_charset.svg",
        char_w = 5,
        char_h = 7,
        imargin = 1,
    )
    for n in range(0x100):
        ll = [0] * 7
        for i in range(7):
            for j in range(5):
                ll[6-i] |= ((cx.m[0x100 + j * 0x100 + n] >> i) & 1) << (4-j)
        cs.set_char(n // 16, n % 16, ll)
    cs.render()

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

    return NAME, (cx.m,)
Exemple #15
0
def example():
    m0 = mem.Stackup(
        files=(("EPROM_C900KBD_R2_3_29_05_84.bin", ), ),
        nextto=__file__,
    )

    cx = mos6500.rockwell6500()
    cx.m.map(m0, 0x800)

    print("CS1 0x%02x" % romsum(cx.m))

    for i, j in LABELS.items():
        cx.m.set_label(i, j)

    for a in range(0xf8c, 0xfec, 8):
        data.Const(cx.m, a, min(a + 8, 0xff4))
    data.Const(cx.m, 0xfec, 0xff3)
    data.Const(cx.m, 0xff3, 0xff9)

    cx.m.set_line_comment(0x88e, "Counter & PA0 IRQ enable")
    cx.m.set_line_comment(0x892, "Counter rate 20k = 50 Hz")
    cx.m.set_line_comment(0x8db, "Race-condition")
    cx.m.set_line_comment(0x967, "Ignore dangling input ?")
    cx.m.set_line_comment(0xad2, "Caps-Lock released ?")

    cx.m.set_block_comment(0x80, 'PORT A - BIT 7 - TXC')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 6 - TXD')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 5 - some key')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 4 - some key')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 3 - CAPS LOCK LED')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 2 - some key')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 1 - in')
    cx.m.set_block_comment(0x80, 'PORT A - BIT 0 - in Host Precense Detect')

    cx.m.set_block_comment(0x81, 'PORT B - KEY MATRIX STROBE')

    cx.m.set_block_comment(0x82, 'PORT C - BIT 7 - some key')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 6 - some key')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 5 -')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 4 -')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 3 -')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 2 -')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 1 -')
    cx.m.set_block_comment(0x82, 'PORT C - BIT 0 -')

    cx.m.set_block_comment(0x83, 'PORT D - KEY MATRIX SENSE')

    cx.m.set_block_comment(
        0x000, '''CBM900 Keyboard controller

There seems to be two parts to the keyboard:

Five real keys are attached directly to port A&C ("some key").

A matrix of keys are strobed by port B and sensed by port D.

Reporting is by scancode, with key release marked by bit 7.

''')

    cx.m.set_block_comment(0x942, '''PA0 edge detect
Send 0xaa, 0x38 to host
''')
    cx.m.set_block_comment(0x951, '''Scan first part of key matrix
''')
    cx.m.set_block_comment(
        0x9e3, '''Scan second part of key matrix
Scan up to 0x68 (@a29) keys
List first ten (@a09) activated keys in LIST1.
''')
    cx.m.set_block_comment(
        0xa2d, '''Compare LIST1 with LIST2
Report key-release
Perform auto-repeat on CURKEY
''')
    cx.m.set_block_comment(0xa6a, '''Report new key-presses
''')

    cx.m.set_line_comment(0xa4e, '''Key-repeat''')

    cx.vectors()

    return NAME, (cx.m, )
Exemple #16
0
def example():
    m0 = mem.Stackup(FILENAMES, nextto=__file__)

    cx = hp_nanoproc.hp_nanoproc_pg()

    # Slightly confusing mapping of memory for this one.  Probably an
    # artifact of a change from smaller to bigger ROMS along the way.
    cx.m.map(m0, 0x0000, 0x1000)
    cx.m.map(m0, 0x2000, 0x3000, 0x1000)
    cx.m.map(m0, 0x1000, 0x2000, 0x2000)
    cx.m.map(m0, 0x3000, 0x4000, 0x3000)

    cx.disass(0)
    cx.disass(0xff)

    cuts = []

    #######################################################################
    if True:
        for a0 in range(4, 0x20, 4):
            cx.disass(a0)
        ix0 = list(cx.m.find(0x54))
        assert len(ix0) == 1
        ix0 = ix0[0]
        ix0.flow_out = list()
        for a0 in range(4, 0x20, 4):
            ix0 += code.Jump(to=a0)
            i = list(cx.m.find(a0))
            assert len(i) == 1
            i = i[0]
            assert len(i.flow_out) == 1
            dpf = i.flow_out[0].to
            cuts.append((None, dpf))
            ix1 = list(cx.m.find(dpf + 6))
            assert len(ix1) == 1
            ix1 = ix1[0]
            ix1.flow_out = list()
            pg = dpf & ~0x7ff
            print("DISP_%d %x" % (a0 >> 2, dpf))
            cx.m.set_label(dpf, "DISP_%d" % (a0 >> 2))
            for a1 in range(pg, dpf, 2):
                ix1 += code.Jump(to=a1)
                cx.disass(a1)
                v = a0 << 3
                v |= (a1 - pg) >> 1
                cx.m.set_label(a1, "PTR_%02x" % v)

    #######################################################################
    def jmp_table(lo, hi, span, txt="table", src=None):
        x = cx.m.add_range(lo, hi, txt="table")
        if src is None:
            ins = None
        else:
            ins = list(cx.m.find(src))
            print("JMPTABLE %x" % src, ins)
            if len(ins) != 1:
                ins = None
            else:
                ins = ins[0]
                assert len(ins.flow_out) == 1
                ins.flow_out = list()
        for a in range(lo, hi, span):
            if ins is not None:
                ins += code.Jump(to=a)
            cx.disass(a)

    if True:
        jmp_table(0x07d0, 0x0800, 8, "table", 0x007f)
        jmp_table(0x0f80, 0x0fa8, 4, "LED segment table", 0xd0e)
        jmp_table(0x0fa8, 0x0fc0, 2, "table", 0x0aae)
        jmp_table(0x0fc0, 0x0fe0, 4, "table", 0x0b2e)
        jmp_table(0x0fe0, 0x1000, 4, "table", 0x0b49)
        jmp_table(0x1840, 0x1870, 8, "table", 0x1b2e)
        jmp_table(0x1fd0, 0x2000, 8, "table", 0x1d01)
        jmp_table(0x2fb8, 0x3000, 8, "table", 0x2f86)
        jmp_table(0x3fd8, 0x4000, 4, "table", 0x3d17)

    return NAME, (cx.m, )
Exemple #17
0
def example():
    m = []
    for fn, csum in FILES:
        i = mem.Stackup(files=(fn,), nextto=__file__,)
        assert sum(i.bytearray(i.lo, i.hi)) & 0xffff == csum
        m.append(i)

    charrom(m[3], m[4])

    cpu = z80.z80()
    cpu.m.map(m[0], 0x0000)
    cpu.m.map(m[1], 0x4000)
    cpu.m.map(m[2], 0xa000)

    cpu.flow_check.append(fc)

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

    for a, b in IO_SYMBOLS.items():
        cpu.as_io.set_label(a, b)

    for a in range(0x3d, 0x60, 2):
        x = cpu.codeptr(a)
        cpu.m.set_line_comment(x.dst, "From tbl@0x003d")

    for a in range(0x0700, 0x0728, 2):
        x = cpu.codeptr(a)
        cpu.m.set_line_comment(x.dst, "From tbl@0x0700")

    for a in range(0x0800, 0x0810, 2):
        x = cpu.codeptr(a)
        cpu.m.set_line_comment(x.dst, "From tbl@0x0800")

    for a in range(0x0900, 0x0908, 2):
        x = cpu.codeptr(a)
        cpu.m.set_line_comment(x.dst, "From tbl@0x0900")

    for a in range(0xe00, 0xfa0, 2):
        x = cpu.codeptr(a)
        cpu.m.set_line_comment(x.dst, "From tbl@0x0e00")

    for a in range(0x0810, 0x0900, 2):
        x = cpu.dataptr(a)
        y = data.Txt(cpu.m, x.dst, term=(0x81,), label=False)
        x.lcmt = y.txt

    for a in range(0x0a45, 0x0be3, 2):
        x = cpu.dataptr(a)
        y = data.Txt(cpu.m, x.dst, term=(0x80,), label=False)
        x.lcmt = y.txt

    for a in range(0x3bb1, 0x3bd1, 2):
        x = cpu.dataptr(a)
        cpu.m.set_label(x.dst, "KBD_%x" % a)
        for i in range(29):
            try:
                y = data.Pstruct(cpu.m, x.dst + i * 5, "B" * 5, fmt=", ".join(["0x%02x"] * 5))
                y.compact = True
            except:
                pass

    hack(cpu, 0x264b)

    a = 0xa51a
    b = 0xa539
    while cpu.m[a] != 0xff:
        x = data.Pstruct(cpu.m, a, "BBB", fmt=", ".join(["0x%02x"] * 3))
        a = x.hi
        y = data.Txt(cpu.m, b, b + 0x1e, label=False)
        b = y.hi
    data.Const(cpu.m, a, a + 1)

    x = data.Pstruct(cpu.m, 0x54a7, "B" * 12, fmt=", ".join(["0x%02x"] * 12))
    x = data.Pstruct(cpu.m, 0xaddd, "B" * 12, fmt=", ".join(["0x%02x"] * 12))
    x = data.Pstruct(cpu.m, 0xa392, "B" * 12, fmt=", ".join(["0x%02x"] * 12))
    x = data.Pstruct(cpu.m, 0xa39e, "B" * 12, fmt=", ".join(["0x%02x"] * 12))
    x = data.Pstruct(cpu.m, 0xacb0, "B" * 10, fmt=", ".join(["0x%02x"] * 10))

    cpu.m.set_label(0xa2c4, "TestNames")
    for a in range(0xa2c4, 0xa384, 0x10):
        x = data.Txt(cpu.m, a, a + 0x10, label=False)

    for a in range(0xade9, 0xae21, 7):
        x = data.Txt(cpu.m, a, a + 0x7, label=True)

    menu_desc(cpu, 0x7103)
    menu_desc(cpu, 0x742b)
    menu_desc(cpu, 0x7689)

    for a, l in (
            (0xa384, 0x7),
            (0xa38b, 0x7),
            (0xae21, 0xa),
            (0xae2c, 0xc),
            (0xae38, 0x7),
            (0xae40, 0x9),
            (0xae4a, 0xa),
            (0xae54, 0xb),
            (0xae5f, 0xf),
            (0xae6f, 0x7),
            (0xae76, 0xb),
            (0xae81, 0x7),
    ):
        x = data.Txt(cpu.m, a, a + l)

    cpu.vectors(
        (
            "RESET",
            "RST08",
            "RST10",
            "RST18",
            "RST28",
            "IRQ",
            "NMI",
        )
    )

    # switch_tbl(cpu.m, 0x0dc0, cpu)
    switch_tbl(cpu.m, 0x32f8, cpu)
    switch_tbl(cpu.m, 0x334a, cpu)
    switch_tbl(cpu.m, 0x33c1, cpu)
    switch_tbl(cpu.m, 0x5328, cpu)
    switch_tbl(cpu.m, 0x5383, cpu)
    switch_tbl(cpu.m, 0x53b9, cpu)
    switch_tbl(cpu.m, 0x53a2, cpu)
    switch_tbl(cpu.m, 0x53af, cpu)

    for a in range(0x789b, 0x78bb, 2):
        y = cpu.dataptr(a)
        data.Txt(cpu.m, y.dst, term=(0x80,))

    for a in (
            0x7926,
            0x7cf7,
            0x7d03,
    ):
        data.Txt(cpu.m, a, term=(0x80,))

    if False:
        # See 0x43cc
        for a in range(0x3d, 0x58, 2):
            y = cpu.codeptr(a)
            cpu.m.set_line_comment(y.dst, "MANUAL from tbl@0x3c")

    if False:
        # See 0x493e
        for a in range(0x800, 0x900, 2):
            y = cpu.codeptr(a)
            cpu.m.set_line_comment(y.dst, "MANUAL from tbl@0x800")

    data.Pstruct(cpu.m, 0x89, "2B", fmt=", ".join(["0x%02x"] * 2))
    for a in range(0x524, 0x56c, 4):
        data.Pstruct(cpu.m, a, "4B", fmt=", ".join(["0x%02x"] * 4))

    for a, b in (
            (0x008b, "via IY"),
            (0x04f6, "via IY"),
            (0x0506, "via IY"),
            (0x0518, "via IY"),
            (0x0fc7, "via xfa0"),
            (0x0fe5, "via xfa0"),
            (0x1006, "via xfa0"),
            (0x1397, None),
            (0x5c03, "via 0xc296"),
            (0x5df9, "via 0xc296"),
            (0x5e25, "via 0xc296"),
            (0x5ecb, "via 0xc296"),
            (0x5f7f, "via 0xc296"),
            (0x5fbc, "via 0xc296"),
            (0xac5a, None),
            (0xb800, None),
            (0xb874, "via 0xc1da ptr"),
            (0xb8db, "via 0xc1d8 ptr"),
            (0xb8e2, "via 0xc1d8 ptr"),
            (0xb8e9, "via 0xc1d8 ptr"),
            (0xb8f0, "via 0xc1d8 ptr"),
            (0xb8f7, "via 0xc1d8 ptr"),
            (0xb844, None),
            (0x3916, "via 0xcf58 ptr"),
            (0x3936, "via 0xcf58 ptr"),
            (0x3948, "via 0xcf58 ptr"),
            (0x39d8, "via 0xcf58 ptr"),
    ):
        cpu.disass(a)
        if not b:
            b = "MANUAL"
        cpu.m.set_line_comment(a, b)

    y = data.Data(cpu.m, 0x4707, 0x4707 + 0x15e)

    if False:
        discover.Discover(cpu)

    return NAME, (cpu.m,)
Exemple #18
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, )
def example():
    mb = mem.Stackup((FILENAME, ), nextto=__file__)
    cx = example_ada.segment_file(mb)
    for a, b, c in (
        (0x057a, 0x0171, "Operand_Class[19]"),
        (0x058d, 0x0189, "Operation[191]"),
        (0x064c, 0x01a1, "Type_Sort[5]"),
        (0x0651, 0x01b9, "Type_Completion_Mode[6]"),
        (0x0657, 0x01d1, "Subprogram_Sort[4]"),
        (0x065b, 0x01e9, "Field_Sort[2]"),
        (0x065d, 0x0201, "Field_Mode[2]"),
        (0x065f, 0x0411, "Extension_Kind[2]"),
        (0x0661, 0x0461, "Unclassed_Action[61]"),
        (0x069e, 0x0479, "Op_Code[32]"),
    ):
        cx.m.set_block_comment(
            a, "Indexed from 0x%04x -- Machine_Code::type %s" % (b, c))
        cx.m.set_label(a, "NAME_" + c)

    for a, l in (
        (0x000b, "Operand_Class'First"),
        (0x000c, "Operand_Class'Last"),
        (0x000f, "Operand_Class"),
        (0x0010, "Operation'First"),
        (0x0011, "Operation'Last"),
        (0x0014, "Operation"),
        (0x0015, "Type_Sort'First"),
        (0x0016, "Type_Sort'Last"),
        (0x0019, "Type_Sort"),
        (0x001a, "Boolean (Is_Visible)"),
        (0x001b, "Boolean (Unsigned)"),
        (0x001c, "Boolean (With_Size)"),
        (0x001d, "Boolean (Access_Protected)"),
        (0x001e, "Boolean (Values_Relative)"),
        (0x001f, "Boolean (Bounds_With_Object)"),
        (0x0020, "Boolean (Not_Elaborated)"),
        (0x0022, "record size (7)"),
        (0x0023, "Type_Option_Set"),
        (0x0028, "Type_Completion_Mode"),
        (0x0034, "Variable_Option_Set"),
        (0x0039, "Subprogram_Sort"),
        (0x003f, "Subprogram_Option_Set"),
        (0x0044, "Exit_Option_Set"),
        (0x0045, "Field_Index'First"),
        (0x0046, "Field_Index'Last"),
        (0x0047, "Integer (Field_Index)"),
        (0x0048, "Field_Index\n(Declare_Type, Discrete_Class, Defined ?)"),
        (0x0049, "Variant_Record_Index'First (subtype af Field_Index)"),
        (0x004a, "Variant_Record_Index'Last"),
        (0x004b,
         "Load top 2 (Field_Index på stakken)\nErstatter LOAD_ENCACHED for subtype ???"
         ),
        (0x004c,
         "Variant_Record_Index (subtype af Field_Index)\n(Declare_Type, Discrete_Class, Defined ?)"
         ),
        (0x004d, "Field_Sort'First"),
        (0x004e, "Field_Sort'Last"),
        (0x0051, "Field_Sort"),
        (0x0056, "Field_Mode"),
        (0x0057, "Field_Op'First"),
        (0x0058, "Field_Op'Last"),
        (0x0059, "0xe pointer til Operation, se evt Guru1 p 56"),
        (0x005a, "Field_Op (subtype af Operation)"),
        (0x005b, "Component_Op'First"),
        (0x005c, "Component_Op'Last"),
        (0x005d,
         "Load top 2 (Field_OP pos på stak)\nErstatter LOAD_ENCACHED for subtype ???"
         ),
        (0x005e, "Component_Op (subtype af Field_Op)"),
        (0x005f, "0xe : Pointer til Operation typen"),
        (0x0060, "record size?"),
        (0x0061, "0x18 : Pointer til Field_Sort"),
        (0x0062, "0x19 : Pointer til Field_Mode"),
        (0x006a, "(Declare_Type, Variant_Record_Class ?)"),
        (0x006b, "0xd : Pointer til Operand_Class typen?"),
        (0x006c, "0xe : Pointer til Operation typen?"),
        (0x006f, "0x16 : Pointer til Field_Index typen?"),
        (0x0072, "0x16 : Pointer til Field_Index typen?"),
        (0x0075, "0x16 : Pointer til Field_Index typen?"),
        (0x0076, "0x1c : Pointer til Access_Spec typen?"),
        (0x007f, "Field_Spec\n(Declare_Type, Variant_Record_Class ?)"),
        (0x0080, "0xd : Pointer til Operand_Class typen?"),
        (0x0081, "0xe : Pointer til Operation typen?"),
        (0x0084, "0x1c : Pointer til Field_Spec typen?"),
        (0x008d, "Field_Spec\n(Declare_Type, Variant_Record_Class ?)"),
    ):
        cx.m.set_line_comment(a, l)

    cx.m.set_block_comment(
        0x5f, "Start på første Variant record (type Access_Spec)")
    cx.m.set_block_comment(0x6b, "Start på Variant record (type Field_Spec)")
    cx.m.set_block_comment(0x80,
                           "Start på Variant record (type Operator_Spec)")
    cx.m.set_block_comment(0x8e, "S**t på Variant record (type Operator_Spec)")

    return NAME, (cx.m, )
                0x4e56,
                0x4eb9,
            ):
                # print("0x%x" % i, "0x%x" % cx.m.bu16(i))
                cx.m.set_line_comment(i, "(discovered)")
                cx.disass(i)
                stop = False
                break
        if stop:
            break

    return cx

def example():
    m0 = mem.Stackup((FILENAME,), nextto=__file__)
    cx = m200_file(m0)
    return "R1K_M200", (cx.m,)

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

if __name__ == '__main__':
    import sys

    if len(sys.argv) == 3:
        mb = mem.Stackup((sys.argv[1],))
        cx = m200_file(mb)
        listing.Listing(cx.m, fn=sys.argv[2], ncol=8, leaf_width=72)
        exit(0)

    listing.Example(example)
def example():
    m0 = mem.Stackup((FILENAME,), nextto=__file__)
    cx = m200_file(m0)
    return "R1K_M200", (cx.m,)
Exemple #22
0
def example():
    m = mem.Stackup(
        FILENAMES,
        nextto=__file__,
    )

    cx = mc6800.mc6800()
    cx.m.map(m, 0x6800)
    nmi = m.bu16(m.hi - 4)
    print("NMI %x" % nmi)
    cx.m.map(m, 0x8000 | nmi, 0x10000, offset=nmi - 0x6800)

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

    def rom(lo, hi):
        cx.m.add_range(lo, hi, txt="ROM")
        s = 0
        for a in range(lo, hi):
            s += cx.m[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 = data.Data(cx.m, i, i + 1, "csum")
        c.rendered = c.tag

    cx.vectors()

    def jmptbl(lo, hi, x=None):
        c = cx.m.add_range(lo, hi, txt="jmptbl (%04x-%04x)" % (lo, hi))
        # c.rendered = c.tag
        n = 0
        for a in range(lo, hi, 2):
            y = cx.codeptr(a)
            if x != None and len(x) > n:
                cx.m.set_label(y.dst, "CMD_" + x[n])
            n += 1

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

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

    def tblx(a):
        c = data.Data(cx.m, a, a + 16, "tblx")
        s = ""
        for i in range(10):
            v = cx.m[a + i]
            s += " %02x" % v
        s += "  "
        for i in range(10, 16):
            v = cx.m[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.table(cx.m,
                        0x7800,
                        0x7810,
                        drive=(128, 64, 32, 16, 8, 4, 2, 1, 0),
                        inv=True,
                        verbose=False)

    return NAME, (cx.m, )
Exemple #23
0
def example():
    m0 = mem.Stackup(FILENAMES, nextto=__file__)

    cx = my68k20()

    cx.flow_check.append(inline_text)
    cx.trap_returns[0] = True

    cx.m.map(m0, 0x0, 0x8)
    cx.m.map(m0, 0x80000000, 0x80002000, 0x0000)
    cx.m.map(m0, 0x80004000, 0x80006000, 0x2000)
    cx.m.map(m0, 0x80002000, 0x80004000, 0x4000)
    cx.m.map(m0, 0x80006000, 0x80008000, 0x6000)
    cx.m.map(m0, 0x00070000, 0x00072000, 0x8000)
    cx.m.map(m0, 0x00072000, 0x00074000, 0xa000)
    cx.m.map(m0, 0x00074000, 0x00076000, 0xc000)
    cx.m.map(m0, 0x00076000, 0x00078000, 0xe000)

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

    resha_section(
        cx.m, 0x70000, {
            0: (None, cx.disass),
            1: (None, cx.disass),
            2: (None, cx.disass),
            3: (None, cx.disass),
            4: (None, cx.disass),
            5: (None, cx.disass),
        })
    resha_section(cx.m, 0x72000, {
        0: (None, cx.disass),
        2: (None, cx.disass),
        3: (None, cx.disass),
    })
    resha_section(cx.m, 0x74000, {
        0: (None, cx.disass),
        1: (None, cx.disass),
    })
    resha_section(cx.m, 0x76000, {
        0: (None, cx.disass),
    })

    cx.disass(0x80000024)
    for a in (
            0x80000072,
            0x80000156,
            0x800001c4,
            0x80000314,
            0x80000374,
            0x80000552,
            0x80002a24,
            0x80002a2c,
            0x800033ce,
            0x80003690,
            0x80004afe,
            0x80004b42,
            0x80004b68,
            0x80007e0b,
    ):
        data.Txt(cx.m, a, label=False, align=2)

    def txts(a, b, align=2, label=False):
        while a < b:
            y = data.Txt(cx.m, a, label=label, align=align, splitnl=True)
            a = y.hi

    txts(0x7063e, 0x70708, align=1)
    txts(0x712a6, 0x71308, align=1)
    txts(0x719f2, 0x71ab8, align=1)
    txts(0x74006, 0x7412c, align=1, label=True)
    txts(0x76248, 0x763b0, align=1)

    for a in range(0x76084, 0x760c8, 4):
        y = cx.dataptr(a)
        data.Txt(cx.m, y.dst)

    for a in range(0x76a4c, 0x76a54, 4):
        y = cx.dataptr(a)
        data.Txt(cx.m, y.dst)

    a = 0x765e4
    while a < 0x76656:
        w = data.Pstruct(cx.m, a, "<H", fmt="0x%x")
        y = cx.dataptr(w.hi)
        if y.dst:
            data.Txt(cx.m, y.dst)
        a = y.hi

    a = 0x7351e
    while True:
        w = data.Pstruct(cx.m, a, "<H", fmt="0x%x")
        if not w.data[0]:
            break
        y = cx.codeptr(w.hi)
        a = y.hi

    for a in range(0x7352e, 0x7353c, 4):
        y = cx.codeptr(a)
        cx.m.set_line_comment(y.dst, "VIA 0x%x" % a)

    for a in range(0x734ea, 0x7351e, 4):
        y = cx.codeptr(a)
        cx.m.set_line_comment(y.dst, "VIA 0x%x" % a)

    for a in range(0x76040, 0x76080, 4):
        y = cx.codeptr(a)
        cx.m.set_line_comment(y.dst, "VIA 0x%x" % a)

    for a in (
            0x7051c,
            0x70554,
            0x705d4,
            0x705df,
            0x705e8,
            0x705f5,
            0x70628,
            0x70746,
            0x709ea,
            0x71010,
            0x71025,
            0x71039,
            0x7104c,
            0x71b10,
            0x7200a,
            0x76128,
            0x762b0,
            0x76a0a,
            0x76a28,
            0x76a46,
            0x76990,
            0x76a46,
            0x76220,
            # 0x77666,
    ):
        data.Txt(cx.m, a)

    txts(0x800010cc, 0x80001122, align=1, label=True)
    txts(0x80001bb0, 0x80001bc2)
    txts(0x80002c14, 0x80002e04, align=1)
    txts(0x80004ece, 0x80004fbf, align=1)
    txts(0x800027ee, 0x800028ca, align=1)

    ##########
    data.Txt(cx.m, 0x8000221c, align=1)
    data.Txt(cx.m, 0x80002232, align=1, splitnl=True)
    data.Txt(cx.m, 0x8000223d, align=1, splitnl=True)
    l = []
    for a in range(0x8000228f, 0x800024a8):
        x = cx.m[a]
        if not x:
            l.append(a)
            break
        if x & 0x80:
            l.append(a)
    for i in range(len(l) - 1):
        data.Txt(cx.m, l[i], l[i + 1], align=1, label=not i)
    data.Txt(cx.m, l[-1] + 1, align=1, label=False)

    # 0x8000298e
    y = data.Txt(cx.m, 0x8000240c, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x80002481, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x8000254e, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x8000256e, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x8000257d, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x8000258c, splitnl=True, align=1)
    y = data.Txt(cx.m, 0x8000259b, splitnl=True, align=1)

    for a, b in (
        (0x704e8, None),
        (0x70708, None),
        (0x72c5e, None),
        (0x730a8, None),  # via 0x734f2
        (0x73134, None),  # via 0x734ee
        (0x73258, None),  # via 0x731b2
        (0x7338a, None),
        (0x73396, None),  # via 0x731b2
        (0x734ca, None),
        (0x733a2, None),
        (0x731b6, None),
        (0x7412e, None),
        (0x7665a, None),
        (0x74208, None),
        (0x74212, None),
        (0x77662, None),
        (
            0x8000000c,
            None,
        ),
        (
            0x80000010,
            None,
        ),
        (
            0x80000014,
            None,
        ),
        (
            0x80000018,
            None,
        ),
        (
            0x8000001c,
            None,
        ),
        (
            0x80000020,
            None,
        ),
        (
            0x800001f6,
            None,
        ),
        (
            0x80000208,
            None,
        ),
        (
            0x8000021a,
            None,
        ),
        (
            0x80001524,
            None,
        ),
        (
            0x80001566,
            None,
        ),
        (
            0x800015a8,
            None,
        ),
        (
            0x80001628,
            None,
        ),
        (
            0x800016c2,
            None,
        ),
        (
            0x80002796,
            None,
        ),
        (
            0x800027ca,
            None,
        ),
        (
            0x80002bbe,
            None,
        ),
        (
            0x80002bc4,
            None,
        ),
        (
            0x800040a0,
            None,
        ),
    ):
        cx.disass(a)
        if not b:
            b = "MANUAL"
        cx.m.set_line_comment(a, b)

    for a in range(0x80002000, 0x80002074, 4):
        cx.disass(a)

    for a in range(0x8000310e, 0x80003122, 4):
        cx.codeptr(a)

    for a in range(0x800038ce, 0x800038ee, 4):
        cx.codeptr(a)

    for a in range(0x80004000, 0x80004008, 4):
        cx.disass(a)

    for a in range(0x800043aa, 0x80004492, 6):
        y = data.Const(cx.m, a, a + 4, func=cx.m.bu32, size=4)
        z = data.Const(cx.m, y.hi, y.hi + 2, func=cx.m.bu16, size=2)
        w = cx.m.bu16(a + 4)
        w >>= 4
        w &= 0xffe
        d = 0x800043aa + w
        cx.disass(d)

    for a in range(0x80004a7a, 0x80004a98, 4):
        d = cx.m.bu32(a)
        data.Dataptr(cx.m, a, a + 4, d)
        data.Txt(cx.m, d, align=1)

    for a in range(0x800036e8, 0x800036fc, 4):
        d = cx.m.bu32(a)
        data.Dataptr(cx.m, a, a + 4, d)
        data.Txt(cx.m, d)

    data.Const(cx.m, 0x80001ffa, 0x80002000)
    data.Const(cx.m, 0x80003ffa, 0x80004000)
    data.Const(cx.m, 0x80005ffa, 0x80006000)
    data.Const(cx.m, 0x80007dfa, 0x80007e00)

    # See 0x800039e0
    data.Const(cx.m, 0x80003a2a, 0x80003a2a + 0x16)

    y = data.Pstruct(cx.m, 0x80007e84, ">L")
    y.lcmt = "Machine Number"

    d = discover.Discover(cx)

    return NAME, (cx.m, )