-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
70 lines (59 loc) · 2.57 KB
/
config.py
File metadata and controls
70 lines (59 loc) · 2.57 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Config: command line arguments for the program
import argparse
class Config:
def __init__(self):
parser = argparse.ArgumentParser()
parser.add_argument("--ramfile", "-r")
parser.add_argument("--address", "-a")
parser.add_argument("--map", "-m")
parser.add_argument("--showstrings", "-s", action="store_true")
parser.add_argument("--lineaddrs", "-l", action="store_true")
parser.add_argument("--nopointer", '-n', action="store_true")
parser.add_argument("--ttyd", "-t", action="store_true")
parser.add_argument("--cpp", "-c", action="store_true")
parser.add_argument("--recursive", "-e", action="store_true")
args = parser.parse_args()
# --ramfile path, -r path
# Path to the MEM1 RAM dump
if args.ramfile is not None:
self.dump_path = args.ramfile
else:
self.dump_path = "ram.raw"
# --address addr, -a addr
# Address of the script to disassemble
# Ex. 80e4a688 for aa1_01_init_evt
if args.address is not None:
self.addr = int(args.address, 16)
else:
self.addr = int(input("addr: "), 16)
# --map path, -m path
# Path to a symbol map, will be used
# Ex. 80e4a688 for aa1_01_init_evt
if args.map is not None:
self.map_path = args.map
else:
self.map_path = None
# --showstrings, -s
# Prints the contents of a string instead of its address for supported instructions, currently can't re-assemble
# enabled: debug_put_msg "aa1_01_init_evt"
# disabled: debug_put_msg 80CAC958
self.show_strings = args.showstrings
# --lineaddrs, -l
# Prints the memory address of an instruction at the start of the line
# enabled: 80e4a688: debug_put_msg 0x80CAC958
# disabled: debug_put_msg 0x80CAC958
self.show_line_addrs = args.lineaddrs
# --nopointer, -n
# Prints 'ptr' instead of actual addresses, useful for comparing code from different builds
# enabled: user_func ptr, 1, 1, ptr, 1073741824
# disabled: user_func 0x800eb72c, 1, 1, 0x80caa0d0, 1073741824
self.no_pointer = args.nopointer
# --ttyd, -t
# Changes to TTYD values for opcodes and vriables
self.spm = not args.ttyd
# --cpp, -c
# Changes output format to C++ preprocessor macros
self.cpp_macros = args.cpp
## --recursive
# Recursively disassembles child scripts
self.recursive = args.recursive