-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
121 lines (98 loc) · 2.11 KB
/
main.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"""
class Instruction():
def __init__(self,string):
self.mnemonic=
self.rd=
self.rs1=
self.rs2=
"""
if __name__ =="__main__":
Dictionary_R = {
'R':["add","sub","sll","slt","sltu","xor","srl","sra","or","and"]
}
Dictionary_I = {
'I':["addi","slli","slti","sltiu","xori","srli","srai","ori","andi"]
}
Dictionary_IJ = {
"IJ":"jalr"
}
Dictionary_L = {
'L':["lb","lh","lw","lbu","lhu"]
}
Dictionary_J = {
'J':["jal"]
}
Dictionary_Ului = {
'Ului':["lui"]
}
Dictionary_Uauipc = {
'Uauipc':["auipc"]
}
Dictionary_S = {
'S':["sb","sh","sw"]
}
Dictionary_B = {
'B':["beq","bne","blt","bge","bltu","bgeu"]
}
Dictionary_OpCode = {
'R':"0110011",
'I':"0010011",
'L':"0000011",
'LR':"1100111",
'S':"1100011",
'B':"0100011",
'J':"1101111",
'Ului':"0110111",
'Uauipc':"0010111"
}
Dictionary_Func3 = {
"add":"000",
"sub":"000",
"sll":"001",
"slt":"010",
"sltu":"011",
"xor":"100",
"srl":"101",
"sra":"101",
"or":"110",
"and":"111",
"addi":"000",
"slli":"001",
"slti":"010",
"sltiu":"011",
"xori":"100",
"srli":"101",
"srai":"101",
"ori":"110",
"andi":"111",
"lb":"000",
"lh":"001",
"lw":"010",
"lbu":"100",
"lhu":"101",
"jalr":"000",
"beq":"000",
"bne":"001",
"blt":"100",
"bge":"101",
"bltu":"110",
"bgeu":"111",
"sb":"000",
"sh":"001",
"sw":"010"
}
Dictionary_Func7 = {
"sub":"0100000",
"sra":"0100000"
}
print("hola")
register=[];
linesList=[]
with open("InputSampleLLL.txt",'r') as Input:
linesList=Input.readlines()
for line in linesList:
elements=line.split(",")
mnemonic=Dictionary_OpCode[elements[0]]
print(mnemonic + "\n")
#with open("OutputSampleHex.txt",'a') as Output:
#Output.write("\ncachorro")