File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,33 @@ def trans(instr_sepa: dict) -> dict:
4040
4141 if flag1 or flag2 :
4242 res_instr .append ({
43- "instr" : instr , "Rs " : instr_sepa [ "RS" ] , "Rt " : instr_sepa [ "RT" ] ,
44- "Rd " : instr_sepa [ "RD" ] , "SA" : instr_sepa [ "SA" ] , "FUNCT" : instr_sepa [ " FUNCT" ]
43+ "instr" : instr , "OP " : OP , "Rs " : RS ,
44+ "Rt " : RT , "Rd" : RD , "SA" : SA , "FUNCT" : FUNCT
4545 })
4646 else :
4747 if len (res_instr ) != 1 :
4848 raise Exception ("Instruction parse failed!" , instr_set [instr ])
4949
50- return res_instr
50+ return res_instr
51+
52+ '''
53+ e.g.
54+ input:
55+ {"val":0x123, "len":12},
56+ {"val":0x456, "len":12},
57+ {"val":0x789, "len":12}
58+ output: 0x123456789
59+
60+ input:
61+ {"val": 0b101011, "len": 6},
62+ {"val": 0b1001011, "len": 7},
63+ {"val": 0b1, "len": 1}
64+ output: 0x2b97
65+ '''
66+ def hexCat (* input_tup ):
67+ assert len (input_tup ) != 0
68+ to_ret = 0
69+ for i in range (len (input_tup )):
70+ # print(input_tup[i]["len"], input_tup[i]["val"].bit_length(), input_tup[i]["len"])
71+ to_ret = (to_ret << input_tup [i ]["len" ]) | input_tup [i ]["val" ]
72+ return hex (to_ret )
You can’t perform that action at this time.
0 commit comments