From d9bebd9b1ff12c5ecc9151337de9fefa0cf0cfff Mon Sep 17 00:00:00 2001 From: Kaya Celebi Date: Mon, 10 Apr 2023 06:37:40 -0400 Subject: [PATCH 1/2] .gitignore update --- .gitignore | 3 ++- .../__pycache__/convert.cpython-38.pyc | Bin 5954 -> 5986 bytes .../__pycache__/parse.cpython-38.pyc | Bin 4133 -> 4133 bytes .../test_class.cpython-38-pytest-7.2.2.pyc | Bin 7584 -> 7576 bytes 4 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cf3feec..1a32213 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist riscv_assembler.egg-info build .pytest_cache/ -deprc_setup.py \ No newline at end of file +deprc_setup.py +__pycache__/ \ No newline at end of file diff --git a/src/riscv_assembler/__pycache__/convert.cpython-38.pyc b/src/riscv_assembler/__pycache__/convert.cpython-38.pyc index 456c6d296760d72967e3d9e088b6223ca3f16cb9..1668e2e3aca3f48ef69063a88137a556618b02a8 100644 GIT binary patch delta 70 zcmX@4_ehU7l$V!_0SH{58mBzj$opJON3tlhIJqo7vA8%jHz_BzNG~(5xTGjPv8d>l KD7w@naVG#^ycxa# delta 39 tcmaE)cSw&nl$V!_0SN9tF-|$Mk@vY64`*gxaY<2pVo}j8*2xOuP5}QA4Kx4% diff --git a/src/riscv_assembler/__pycache__/parse.cpython-38.pyc b/src/riscv_assembler/__pycache__/parse.cpython-38.pyc index cf5d2584b5c4092ffabec818651ab10c0b4d83c8..932fcfeef792ed0b1b30e8aef8fd5a7eff195bc3 100644 GIT binary patch delta 25 fcmZ3guvCF7l$V!_0SG*wZsc0a&vcYyZRAUpVU;c}O4gfPBBR7A31V%YF2l$O0Q9B{I{*Lx From ff759d3c713e423134c98f190638f50fccddaf83 Mon Sep 17 00:00:00 2001 From: Kaya Celebi Date: Mon, 10 Apr 2023 07:50:40 -0400 Subject: [PATCH 2/2] SB and JUMP working --- .../__pycache__/convert.cpython-38.pyc | Bin 5986 -> 5986 bytes .../__pycache__/instr_arr.cpython-38.pyc | Bin 13312 -> 13490 bytes .../__pycache__/parse.cpython-38.pyc | Bin 4133 -> 4110 bytes src/riscv_assembler/instr_arr.py | 36 +++++++++--------- src/riscv_assembler/parse.py | 30 +++++++-------- .../test_class.cpython-38-pytest-7.2.2.pyc | Bin 7576 -> 7958 bytes tests/test_class.py | 4 +- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/riscv_assembler/__pycache__/convert.cpython-38.pyc b/src/riscv_assembler/__pycache__/convert.cpython-38.pyc index 1668e2e3aca3f48ef69063a88137a556618b02a8..8ab836d006916f3e9eecb163a8f7a643e8238a30 100644 GIT binary patch delta 19 ZcmaE)_ehT`l$V!_0SNv-+sG9m4gfm`1+xGE delta 19 ZcmaE)_ehT`l$V!_0SH{5Zsdv(2LLvv1o!{| diff --git a/src/riscv_assembler/__pycache__/instr_arr.cpython-38.pyc b/src/riscv_assembler/__pycache__/instr_arr.cpython-38.pyc index 18b4a221b2c6c4654f8165af41191c12886d7db7..ba150fa5dbfb586661dd5ad861e26017d07f8d8c 100644 GIT binary patch literal 13490 zcmc&)>u+4gb-%BD@F|L-9+Yf(Wz)9SmZ^s=E3su+mh3o`ZAK=;xVe_SUGBLgm)e)+ z?n*MfOd3m(R?Ua6zG>CZJadf?>BcJ zcb5+@Ya89goI7XkJkR{jnKN@|ZfL0A!0#9T^`saRhVe5p(ce)p7ZLpTEW;2(%z{xg zUDIUTDp*C^wRPMsIBrZFiAh`%l9WE_mjM}+AsLoEG9r6rRQAc3?3V*_P!28bcjGS` zGA@Vj7;<>caueW=$bI1M^Ac;en*@Kq90h+=^L^kSkQDfo=KH}PlLx^+sQCf#56J}h z3C$0Je^?#?|A^*?z&|R-!5>F!!{E~L7`Vs0VYIdf{Nr*0{0YsEfPX?J!B1*_FZh#k z3j8U}kAgofXTYD){66qc%2VK<()<|sv+^|fr!~LdJK!Dk4tWRV+>adjiVWOw+;RD; zJaflz56iQ19?v6Qa?SAi5c&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{YNf?J`Rr=Knkh z!?-h~OmBzv<2<#Nha4Cl(y!_ZxR!cQThU6|iVpJ*Nvr>#jl0%8?1h(cS#{Br)63@F z7RYwCQ}vV5$qQl+m#^yOlIOn_PXl1}5{?^1OJS5hg8*Ebi%XdsH; zMGd|QyC=V|Vs5#NE5l{4;hQjbFm$p^lJ^aA`KnMx@)q(m=19wBMJ1`s-}22$0~LT^ z#y}f>4Aez!qIA=@KoFHq1=HzN8uAX?G|F?*4I%=^8*|7}zD{xrrRSY$!C6YE*F;G* zsHj&0PRd@XA-~6>=m=~xy8sJKGi{-($U=jDi#f~cC7Z8&>6WasT+HG9VL$H70e*{q z>~eNy=8fQ$4PKZ1xJsM~-r45+@|175w-DwKt|Or9bIuJAAlRHMdmu%}w-9T979ETw z-ze1!7*_**#7Pg5of}J_Rc8r8D9I1lBYnX)79{w*{207^pX5V+f!v@ht}5fQ3|e3_ zWhXP~C#WRl(p;cqskxE|V3n#xX|kw=i^kV|y~4|w>b|tx&uUMTyhOq~5b7Ua^)H%y zi|jlJ4=^QvX4Zquj;=d+A>L_CgUXZR%DVSMbbyoRs$7FBh62q#YGa__&rAp zO?B?HL{&-anikJ~+I0cx)&!JTN?lz~AoS@sR_` yq2#V(`h-4&bqv3t&im2-vif(BySv_>TZ7Hg|7*n}^?*wn@#xq#_Tv{;^8WzxrOS5! diff --git a/src/riscv_assembler/__pycache__/parse.cpython-38.pyc b/src/riscv_assembler/__pycache__/parse.cpython-38.pyc index 932fcfeef792ed0b1b30e8aef8fd5a7eff195bc3..dbb86b1664c465a3863f180c7b178d7f021eb3d4 100644 GIT binary patch delta 2103 zcmZuyO>7fK6rMM`-d#JkR7F_0FN~d*c`abgg~!=K0N=H{bi-?2i+7 zC$gVrGAV{n{MVHDIkT1>zcGU|!36m15{=x4DlZs7y5XDEL?MB?S%!jjj){b@R++F? zc)^zT3M)9mo@cJ}m_oV`!vPfO+2vX(tki3l?ldIMEqS{Vguz;CEM=qHX?%m<*S_D^ z5qqUA9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a z+iBd{#xF-Atw#;gUr&;*yBO+8SW`s1vZyIRU0%CdVynd;kanU^u9xGxmWw-zJwx5C zD*Ty7N$|Of;0sgPdu|4A8nmZT72HuRBiGKlyZ_{#znB@at+g%D|C-TMXZ0#3{Afn* gR-Y9giopZ+9SdZuH!};}qT7`rhgD(YvS_^c53x|P761SM diff --git a/src/riscv_assembler/instr_arr.py b/src/riscv_assembler/instr_arr.py index 91f4aa2..27f1bd8 100644 --- a/src/riscv_assembler/instr_arr.py +++ b/src/riscv_assembler/instr_arr.py @@ -4,7 +4,7 @@ __all__ = [ 'R_instr', 'I_instr', 'S_instr', - 'SB_instr', 'U_instr', 'UJ_instr','pseudo_instr', + 'SB_instr', 'U_instr', 'UJ_instr','pseudo_instr', 'JUMP', 'R', 'I', 'S', 'SB', 'U', 'UJ', 'Rp', 'Ip', 'Sp', 'SBp', 'Up', 'UJp', 'Psp'] @@ -69,7 +69,8 @@ def compute_instr(self, instr, rs1, imm, rd): @staticmethod def immediate(imm): #return int(imm) - ((int(imm)>>12)<<12) # imm[11:0] - return format(int(imm), '012b') + return format(((1 << 12) - 1) & int(imm), '012b') + #return format(int(imm), '012b') class _S(Instruction): def __repr__(self): @@ -97,7 +98,7 @@ def immediate(imm, n): mod_imm_2 = int(imm) - ((int(imm) >> 5) << 5) # imm[4:0] return mod_imm, mod_imm_2''' - mod_imm = format(((1 << 13) - 1) & int(imm), '013b') + mod_imm = format(((1 << 12) - 1) & int(imm), '012b') if n == 1: return mod_imm[0] + mod_imm[12-10 : 12-4] return mod_imm[12-4 : 12 - 0] + mod_imm[1] @@ -127,8 +128,8 @@ def compute_instr(self, instr, rs1, rs2, imm): def immediate(imm, n): mod_imm = format(((1 << 13) - 1) & int(imm), '013b') if n == 1: - return mod_imm[12-12] + mod_imm[12-10:12-5] - return mod_imm[12-4:12-1] + mod_imm[12-11] + return mod_imm[12-12] + mod_imm[12-11:12-5] + return mod_imm[12-4:12-0] + mod_imm[12-11] class _U(Instruction): def __repr__(self): @@ -201,10 +202,11 @@ def __str__(self): return "I Parser" def organize(self, tokens): + line_num, code = tokens[-2], tokens[-1] instr, rs1, imm, rd = tokens[0], None, None, None if instr == "jalr": if len(tokens) == 4: - rs1, imm, rd = reg_map[tokens[2]], JUMP(tokens[3]), reg_map[tokens[1]] + rs1, imm, rd = reg_map[tokens[2]], JUMP(tokens[3], line_num, code), reg_map[tokens[1]] else: rs1, imm, rd = reg_map[tokens[1]], 0, reg_map["x1"] elif instr == "lw": @@ -235,7 +237,8 @@ def __str__(self): return "SB Parser" def organize(self, tokens): - instr, rs1, rs2, imm = tokens[0], reg_map[tokens[1]], reg_map[tokens[2]], JUMP(tokens[3]) + line_num, code = tokens[-2], tokens[-1] + instr, rs1, rs2, imm = tokens[0], reg_map[tokens[1]], reg_map[tokens[2]], JUMP(tokens[3], line_num, code) return SB(instr, rs1, rs2, imm) class _U_parse(InstructionParser): @@ -259,11 +262,12 @@ def __str__(self): return "UJ Parser" def organize(self, tokens): + line_num, code = tokens[-2], tokens[-1] instr, imm, rd = tokens[0], None, None if len(tokens) == 3: - imm, rd = JUMP(tokens[2]), reg_map[tokens[1]] + imm, rd = JUMP(tokens[2], line_num, code), reg_map[tokens[1]] else: - imm, rd = JUMP(tokens[1]), reg_map["x1"] + imm, rd = JUMP(tokens[1], line_num, code), reg_map["x1"] return UJ(instr, imm, rd) @@ -292,27 +296,25 @@ def organize(self, tokens): return BadInstructionError() -def JUMP(x : str, line_num : int) -> int: - raise NotImplementedError() - +def JUMP(x : str, line_num : int, code: list) -> int: # search forward skip_labels = 0 - for i in range(line_num, len(self.code)): - if x+":" == self.code[i]: + for i in range(line_num, len(code)): + if x+":" == code[i]: jump_size = (i - line_num - skip_labels) * 4 # how many instructions to jump ahead return jump_size - if self.code[i][-1] == ':': + if code[i][-1] == ':': skip_labels += 1 # search backward skip_labels = 0 for i in range(line_num, -1, -1): # substruct correct label itself - if self.code[i][-1] == ':': + if code[i][-1] == ':': skip_labels += 1 - if x+":" == self.code[i]: + if x+":" == code[i]: jump_size = (i - line_num + skip_labels) * 4 # how many instructions to jump behind return jump_size diff --git a/src/riscv_assembler/parse.py b/src/riscv_assembler/parse.py index 13dd736..643bc53 100644 --- a/src/riscv_assembler/parse.py +++ b/src/riscv_assembler/parse.py @@ -1,5 +1,6 @@ from riscv_assembler.instr_arr import * from types import FunctionType as function +from os.path import exists __all__ = ['Parser'] class _Parser: @@ -18,13 +19,12 @@ class _Parser: ''' def __call__(self, *args) -> list: - if _Parser.is_file(*args): - return _Parser.interpret_file(_Parser.read_file(*args)) - return [_Parser.interpret(_Parser.tokenize(x)) for x in args[0].split("\n") if len(_Parser.tokenize(x)) > 0] - - @staticmethod - def is_file(x : str) -> bool: - return True if '.s' in x or '/' in x else False + if exists(*args): + return _Parser.interpret_arr(_Parser.read_file(*args)) + #return [_Parser.interpret(_Parser.tokenize(x)) for x in args[0].split("\n") if len(_Parser.tokenize(x)) > 0] + elif type(args[0]) == str: + return _Parser.interpret_arr(args[0].split('\n')) + return _Parser.interpret_arr(*args) ''' In read_file(), Check if the inputted line is appropriate before @@ -35,7 +35,7 @@ def valid_line(x : str, allow_colon : bool = False) -> bool: if x[0][0] == "#" or x[0][0] == "\n" or x[0][0] == "" or x[0][0] == ".": return False - if not allow_colon and x[0][-1] == ":" : + if not allow_colon and x[-1] == ":" : return False return True @@ -76,13 +76,13 @@ def read_file(file : str) -> list: file.close() return code''' with open(file) as f: - return f.readlines() + return [x.strip() for x in f.readlines() if x != '\n'] @staticmethod - def interpret_file(code : list) -> list: + def interpret_arr(code : list) -> list: int_code = [] - for line in code: - tokens = _Parser.tokenize(line) + for line_num, line in enumerate(code): + tokens = _Parser.tokenize(line, line_num, code) int_code += [_Parser.interpret(tokens) for _ in range(1) if len(tokens) != 0] return int_code @@ -91,12 +91,12 @@ def interpret_file(code : list) -> list: Tokenize a given line ''' @staticmethod - def tokenize(line : str) -> list: + def tokenize(line : str, line_num: int = None, code : list = None) -> list: line = line.strip() - if len(line) > 0 and _Parser.valid_line(line, True): + if len(line) > 0 and _Parser.valid_line(line): tokens = _Parser.handle_inline_comments(line).split() tokens = _Parser.handle_specific_instr(tokens) - return tokens + return tokens + [line_num, code] if line_num != None and code != None else tokens return [] ''' diff --git a/tests/__pycache__/test_class.cpython-38-pytest-7.2.2.pyc b/tests/__pycache__/test_class.cpython-38-pytest-7.2.2.pyc index 9d89ef7fe25c2972246ec4ee6a9eeba43dc88f66..fdf57f5f60ee03ed6ba6c8430be90073ab62a367 100644 GIT binary patch delta 320 zcmbPXJoR2QvVNdPSfB delta 92 zcmbPcH^Z7Yl$V!_0SL688K?Z7$ScbzwNYD&k(Du+LDO<`5MzkMW>IN%M#k958~9}> tN6D;UjG4?V+s+mT)S{`ed4jAUBU>zxT@*KYjhq^z-Q>%1cFgP?%m4{%72W^< diff --git a/tests/test_class.py b/tests/test_class.py index 8829373..792d623 100644 --- a/tests/test_class.py +++ b/tests/test_class.py @@ -155,8 +155,8 @@ def test_11(): assert func11() == [] # Test file test2.s, need to implement JUMP -#def test_12(): -# assert func12() == ['0x00a00413', '0x00a00493', '0x00848263', '0xfe040493'] +def test_12(): + assert func12() == ['0x00a00413', '0x00a00493', '0x00848263', '0xfe040493'] def test_13(): assert func13() == ['0x00812023']