Skip to content

Commit

Permalink
Check for overlapping fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkryukov committed May 14, 2022
1 parent 301686e commit 2338d86
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,19 @@ def process_enc_line(line, ext):
# check if all args of the instruction are present in arg_lut present in
# constants.py
args = single_fixed.sub(' ', args).split()
encoding_args = ['-'] * 32
for a in args:
if a not in arg_lut:
logging.error(f' Found variable {a} in instruction {name} whose mapping in arg_lut does not exist')
raise SystemExit(1)
else:
(msb, lsb) = arg_lut[a]
for ind in range(lsb, msb):
# overlapping bits
if encoding_args[ind] != '-':
logging.error(f' Found variable {a} in instruction {name} overlapping {encoding_args[ind]} variable')
raise SystemExit(1)
encoding_args[ind] = a

# update the fields of the instruction as a dict and return back along with
# the name of the instruction
Expand Down

0 comments on commit 2338d86

Please sign in to comment.