-
Notifications
You must be signed in to change notification settings - Fork 3
/
disassemble_f3.py
executable file
·55 lines (40 loc) · 1.63 KB
/
disassemble_f3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
filename = "roms/Diag_F3_Rev_1.0.BIN"
from diag_common import *
base_address = 0x9000
functions = [
(0x09a, 0x112, "WriteString"), # Writes null-terminated string to serial
(0x0b0, 0x102, "ReadChar"),
(0x0ba, 0x110, "WriteHexWord"), # Prints out a 4 digit BCD number as ASCII to serial
(0x0c5, 0x10a, "WriteHexByte"), # Prints out a 2 digit BCD number as ASCII to serial
(0x0f6, 0x104, "FinishTest"), # Prints Pass or Fail. checks 0x108 to see if test passed or failed
(0x128, 0x10e, "PressSpaceThenExit"),
(0x164, 0x106, "PrintCtrlCToExit"), # prints out "(CONTROL-C TO EXIT)"
(0x180, 0, "Init"),
(0x1e3, 0x118, "Fn_1e3"),
(0x286, 0x10c, "Fn_286"),
(0x0a3, 0, "WriteByte"),
]
labels = [
(0x9156, "repeat_test", "Resets stack, takes 16bit test start address from RT"),
]
def annotate(memory, entry_points, memory_addr_info):
#scan_calls(memory, base_address, base_address)
for (addr, indirect_addr, name) in functions:
memory_addr_info[base_address + addr].label = name
if indirect_addr != 0:
memory_addr_info[indirect_addr].label = name
entry_points.append(base_address + addr)
# print(entry_points)
# for entry in entry_points:
# print(f"({entry & 0xfff:#05x}, \"\"),")
# exit()
entry_points.append(0x92d7)
entry_points.append(0x9395)
entry_points.append(0x9395)
entry_points.append(0x95f1)
entry_points.append(0x96a4)
entry_points.append(0x9750)
body_addr = parse_header(memory, base_address, base_address)
scan_strings(memory, body_addr)
scan_call_args(memory, body_addr)