blob: db00fbcd9d44b54fd0a71854c86aa7185c411331 (
plain)
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
|
#!/usr/bin/env python3
mnems = """
nop
rot
nrt
dup
swp
ovr
drp
tck
nip
equ
neq
add
sub
mul
div
neg
slt
ult
sle
ule
lod
sto
psh
pop
hlt
put
""".split()
mnems.extend(['???']*(64-len(mnems)))
def opws(kw):
for k in range(16):
mnems.append(kw + str(k))
opws("mark") # who is mark
opws("loc")
opws("ret")
opws("lit")
if __name__ == "__main__":
print("type op = enum u8 {")
for opc,mnem in enumerate(mnems):
if mnem != "???":
print(f"\t{mnem.upper()} = {opc},")
print("};")
|