@@ -75,15 +75,19 @@ def __init__(self):
7575
7676 def parse (self , ** kwargs ):
7777 try :
78+ self ._line = kwargs ['line' ]
7879 self ._arg = kwargs ['arg' ][0 ]
7980 self ._val = int (kwargs ['arg' ][1 :3 ])
8081 except KeyError :
8182 pass
83+ except :
84+ print (f"[ERROR] Invalid instruction at line { self ._line } ." )
8285 if self ._arg == "9" :
8386 self ._arg = kwargs ['arg' ]
8487 try :
8588 return self ._syntax [self ._arg ]
8689 except :
90+ print (f"[ERROR] Invalid instruction at line { self ._line } ." )
8791 return
8892
8993 @accumulate
@@ -98,7 +102,7 @@ def __sub(self, acc, storage) -> int:
98102
99103 @storage
100104 def __sta (self , acc , storage ):
101- storage ._spaces [self ._val ] = acc .value
105+ storage ._spaces [self ._val ] = str ( acc .value )[ - 3 :]
102106
103107 @storage
104108 def __lda (self , acc , storage ):
@@ -129,15 +133,17 @@ def __sft(self, acc, storage):
129133 # Left shift first
130134 if int (self ._val [0 ]) > 0 :
131135 shifts = int (self ._val [0 ])
136+ tmp = str (acc .value )
132137 for _ in range (shifts ):
133- acc . value = f"{ acc . value } 0"
134- acc .value = acc . value [- 3 :]
138+ tmp = f"{ tmp } 0"
139+ acc .value = tmp [- 3 :]
135140 # Right shift second
136141 if int (self ._val [1 ]) > 0 :
137142 shifts = int (self ._val [1 ])
143+ tmp = str (acc .value )
138144 for _ in range (shifts ):
139- acc . value = f"0{ acc . value } "
140- acc .value = acc . value [0 :3 ]
145+ tmp = f"0{ tmp } "
146+ acc .value = tmp [0 :3 ]
141147 acc .value = int (acc .value )
142148
143149 @inputs
0 commit comments