Skip to content

Commit

Permalink
Print better error for invalid machine instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
wallento committed Oct 30, 2018
1 parent 66cbe6f commit 07332e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion riscvmodel/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def machinsn_decode():

if "insn" in args:
for i in args.insn:
print(decode(int(i,16)))
try:
print(decode(int(i,16)))
except MachineDecodeError:
print("Cannot decode {:08x}, invalid instruction".format(int(i,16)))
elif "filename" in args:
temp = mkstemp(suffix='.bin')
subprocess.call([args.objcopy, '-O', 'binary', args.filename, temp[1]])
Expand Down

0 comments on commit 07332e7

Please sign in to comment.