first draft of the script to translate the code
This commit is contained in:
parent
f3ac463013
commit
88cc4fe7e7
1 changed files with 37 additions and 0 deletions
37
post-process.py
Normal file
37
post-process.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
opToBinOP = {
|
||||
"ADD": 1,
|
||||
"MUL": 2,
|
||||
"SUB": 3,
|
||||
"DIV_INT": 4,
|
||||
"COP": 5,
|
||||
"AFC": 6,
|
||||
"JMP": 7,
|
||||
"JMF": 8,
|
||||
"INF": 9,
|
||||
"SUP": 10,
|
||||
"EQ": 11,
|
||||
"PRI": 12,
|
||||
"AND": 13,
|
||||
"OR": 14,
|
||||
"NOT": 15
|
||||
}
|
||||
|
||||
def convertToRegister(s):
|
||||
l = []
|
||||
match s[0]:
|
||||
case "AFC" :
|
||||
# TODO
|
||||
|
||||
|
||||
fileInput = open("asm", "r")
|
||||
ASMLines = list(map(lambda e: e.rstrip("\n"), fileInput.readlines()))
|
||||
print(ASMLines)
|
||||
finalCode = []
|
||||
for i, l in enumerate(ASMLines):
|
||||
items = l.split(" ")
|
||||
finalCode.extend(convertToRegister(items))
|
||||
# idée pour les jumps : quand on voit un jump à la ligne tant on peut ajouter un label là-bas
|
||||
|
||||
# - trucs en registre
|
||||
# - décaler les Jumps
|
||||
# - COP -> OPCode
|
Loading…
Reference in a new issue