-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRMALtokenGenerator.py
More file actions
101 lines (72 loc) · 1.88 KB
/
RMALtokenGenerator.py
File metadata and controls
101 lines (72 loc) · 1.88 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from pyperclip import copy
instructions = [
"nop",
"mov",
"push",
"pop",
"add",
"sub",
"mul",
"div",
"inc",
"dec",
"inx8",
"inx16",
"inx32",
"outx8",
"outx16",
"outx32",
"ret"
]
registers = [
"eax",
"ecx",
"edx",
"ebx",
"esp",
"ebp",
"esi",
"edi"
]
maxInstructionNameLength = len(max(instructions, key=len))
maxRegisterNameLength = len(max(registers, key=len))
instructionsName = f"UGSMGlyphCode instructionsName[{len(instructions)}][{maxInstructionNameLength}] = {{"
registersName = f"UGSMGlyphCode registersName[{len(registers)}][{maxRegisterNameLength}] = {{"
for i, instruction in enumerate(instructions):
instructionsName += "\n { "
if (len(instruction) == 0):
instructionsName += "0"
for j, char in enumerate(instruction):
instructionsName += str(ord(char) - 33 + 4)
if (j != (len(instruction) - 1)):
instructionsName += ", "
if (len(instruction) < maxInstructionNameLength):
instructionsName += ", "
for j in range(maxInstructionNameLength - len(instruction)):
instructionsName += "0"
if (j != (maxInstructionNameLength - len(instruction) - 1)):
instructionsName += ", "
instructionsName += " }"
if (i != (len(instructions) - 1)):
instructionsName += ","
instructionsName += "\n"
instructionsName += "};\n"
for i, register in enumerate(registers):
registersName += "\n { "
for j, char in enumerate(register):
registersName += str(ord(char) - 33 + 4)
if (j != (len(register) - 1)):
registersName += ", "
if (len(register) < maxRegisterNameLength):
registersName += ", "
for j in range(maxRegisterNameLength - len(register)):
registersName += "0"
if (j != (maxRegisterNameLength - len(register) - 1)):
registersName += ", "
registersName += " }"
if (i != (len(registers) - 1)):
registersName += ","
registersName += "\n"
registersName += "};\n"
result = f"{instructionsName}\n\n{registersName}"
copy(result)