-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopcodes.py
52 lines (46 loc) · 887 Bytes
/
opcodes.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
names = [
"LIT",
"INC",
"POP",
"DUP",
"NIP",
"SWP",
"OVR",
"ROT",
"EQU",
"NEQ",
"GTH",
"LTH",
"JMP",
"JCN",
"JSR",
"STH",
"LDZ",
"STZ",
"LDR",
"STR",
"LDA",
"STA",
"DEI",
"DEO",
"ADD",
"SUB",
"MUL",
"DIV",
"AND",
"ORA",
"EOR",
"SFT",
]
def generate_opcode_offsets(counter_width=7, add_uxntal_offset=True):
TWO = 1 << counter_width
K = 2 << counter_width
uxntal_offset = 0x100 if add_uxntal_offset else 0x000
offsets = {}
for opcode_num, opcode in enumerate(names):
base_offset = opcode_num << (counter_width + 2)
offsets[opcode] = (base_offset) + uxntal_offset
offsets[opcode+"k"] = (base_offset | K) + uxntal_offset
offsets[opcode+"2"] = (base_offset | TWO) + uxntal_offset
offsets[opcode+"2k"] = (base_offset | TWO | K) + uxntal_offset
return offsets