コード例 #1
0
def task(pj, cx):
    pj.todo(0x0000, cx.disass)

    # 0x70e5
    pj.todo(0x0027, cx.disass)

    pj.todo(0x0066, cx.disass)

    x = data.Const(pj, 0x0068, 0x0800)
    x.typ = ".BYTE"
    x.fmt = "{Payload moved to 0x7000}"

    pj.todo(0x70d0, cx.disass)

    pj.todo(0x7322, cx.disass)
    pj.todo(0x7615, cx.disass)

    # Interrupt vector table
    for a in range(16):
        cx.codeptr(pj, 0x7300 + a * 2)

    data.Txt(pj, 0x707d, 0x707d + 0x14, label=False)
    data.Txt(pj, 0x70b0, 0x70b0 + 0xf, label=False)
    data.Txt(pj, 0x7092, 0x7092 + 0x1d, label=False)
    data.Txt(pj, 0x73f0, 0x73f0 + 0x12, label=False)
    data.Txt(pj, 0x7071, 0x7071 + 0x6, label=False)
    data.Txt(pj, 0x7077, 0x7077 + 0x6, label=False)

    discover.Discover(pj, cx)

    pj.set_label(0x7068, "memcpy(BC, DE,  L)")
コード例 #2
0
def round_3(cx):
    ''' Discovery, if no specific hints were encountered '''
    for a, b in cx.m.gaps():
        for i in range(a, b, 4):
            if not cx.m[i] == 0xe0:
                continue
            j = cx.m.bu32(i)
            if a <= j < b:
                if cx.m.bu16(j) == 0x4e56:
                    cx.disass(j)
    discover.Discover(cx)
コード例 #3
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, )
コード例 #4
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,)
コード例 #5
0
def example():
    top = 0
    for obj in M200S:
        top = max(top, obj.load_address() + obj.size)
    m = mem.ByteMem(0, top)
    for obj in M200S:
        print("Load", obj, "at 0x%x" % obj.load_address())
        a = obj.load_address()
        for i in range(obj.size):
            m[a + i] = obj.m[i]

    cx = m68020.m68020()
    cx.m.map(m, 0)
    cx.flow_check.append(flow_check)
    cx.trap_returns[0] = False
    cx.it.load_string(mytrap_desc, mytrap_ins)

    cx.m.set_label(0x80002028, "INLINE_PUTS")

    if True:
        for a in (0x08ad6, ):
            data.Const(cx.m, a, a + 2)

    cx.vectors()

    for obj in M200S:
        ep = obj.entry_point()
        cx.m.set_label(ep, "ENTRYPOINT_%s" % str(obj))
        cx.disass(obj.entry_point())

    cx.disass(0x08ad2)

    if True:
        data.Txt(cx.m, 0x294cc, 0x294da)

    if True:
        for a in range(0x09080, 0x09098, 4):
            cx.disass(a)
    if True:
        for a in range(0x10460, 0x1061e, 6):
            cx.disass(a)
    if True:
        for a in range(0x10280, 0x10460, 4):
            cx.disass(a)

    if True:
        switch(cx, 0x13368, 0x1336e)
        switch(cx, 0x14552, 0x14556)
        switch(cx, 0x1635e, 0x16374)
        switch(cx, 0x164b4, 0x164c4)
        switch(cx, 0x16852, 0x16858)
        switch(cx, 0x19536, 0x1953e)
        switch(cx, 0x22cf6, 0x22cfe)
        switch(cx, 0x2413c, 0x24142)
        switch(cx, 0x255fc, 0x25602)
        switch(cx, 0x257a8, 0x257b2)
        switch(cx, 0x293b6, 0x293c4)

    if True:
        for a in range(0x02448, 0x02454, 4):
            cx.disass(a)
        for a in range(0x03b74, 0x03b84, 4):
            cx.disass(a)
        for a in range(0x04276, 0x04282, 2):
            cx.disass(a)

    if True:
        for lo, hi in (
            (0x04dbc, 0x04dd0),
            (0x06596, 0x065ae),
            (0x06642, 0x0665a),
            (0x09378, 0x09398),
        ):
            for a in range(lo, hi, 4):
                y = cx.codeptr(a)
                cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x04fca, 0x04fda, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x062dc, 0x062f8, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x093c4, 0x093fc, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x09495, 0x0956d, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x09578, 0x095a4, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x095e8, 0x0969c, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x096c4, 0x096e4, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x097bc, 0x0983c, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x09850, 0x09894, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x06026, 0x06036, 4):
            y = cx.codeptr(a)
            cx.m.set_label(y.dst, "PTR_FM_%x" % a)
        for a in range(0x20004, 0x20020, 4):
            if cx.m.bu32(a) and a != 0x20010:
                y = cx.codeptr(a)
                cx.m.set_label(y.dst, "PTR_FM_%x" % a)

    if True:
        for lo, hi in (
            (0x09100, 0x0912a),
            (0x0929b, 0x092a9),
            (0x092bc, 0x0933a),
            (0x09398, 0x093c2),
        ):
            for a in range(lo, hi, 2):
                y = cx.m.bu16(a)
                data.Const(cx.m, a, a + 2, func=cx.m.bu16, size=2, fmt="0x%x")
                cx.disass(y)
                cx.m.set_label(y, "PTR_FM_%x" % a)

    if True:
        for a in range(0x092ac, 0x092bc, 4):
            data.Const(cx.m, a, a + 4)

    if True:
        for a in (
                0x02602,
                0x02886,
                0x02c2e,
                0x02e00,
                0x02efe,
                0x0317c,
                0x036a6,
                0x03b3c,
                0x03b4a,
                0x03e6a,
                0x03e78,
                0x03e86,
                0x03e94,
                0x03ea0,
                0x03eae,
                0x03eb6,
                0x03ebc,
                0x03eca,
                0x0409c,
                0x04198,
                0x041a4,
                0x041b6,
                0x04354,
                0x04480,
                0x04486,
                0x044b2,
                0x045e2,
                0x045ec,
                0x0460a,
                0x048fc,
                0x04950,
                0x049d8,
                0x04dd0,
                0x04fa8,
                0x051f6,
                0x05c02,
                0x05d28,
                0x06492,
                0x066ca,
                0x069da,
                0x06a22,
                0x06aea,
                0x06da2,
                0x06df8,
                0x07208,
                0x07286,
                0x07b84,
                0x085ee,
                0x0871a,
                0x087a4,
                0x087b0,
                0x087fe,
                0x0889a,
                0x088cc,
                0x08914,
                0x0895c,
                0x08a70,
                0x08b44,
                0x08b4c,
                0x08b72,
                0x08d14,
                0x08d14,
                0x1070c,
                0x11582,
                0x118a2,
                0x11a36,
                0x124a8,
                0x12836,
                0x13954,
                0x15720,
                0x16cf2,
                0x16f50,
                0x1878a,
                0x22522,
                0x225aa,
                0x225ba,
                0x22730,
                0x22ae2,
                0x23bb4,
                0x286b0,
                0x290da,
                0x294b0,
        ):
            cx.disass(a)

    if False:
        d = discover.Discover(cx)

    return NAME, (cx.m, )