Skip to content

Commit

Permalink
trace: Small improvement for endianess reversion
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti committed Aug 28, 2024
1 parent 299bd7a commit b97cc73
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions util/trace/gen_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ def load_opcodes():
def disasm_inst(hex_inst, mc_exec='llvm-mc', mc_flags='-disassemble -mcpu=snitch'):
"""Disassemble a single RISC-V instruction using llvm-mc."""
# Reverse the endianness of the hex instruction
inst_fmt = ' '.join(
[f'0x{hex_inst[i:i+2]}' for i in range(0, len(hex_inst), 2)][::-1]
)
inst_fmt = ' '.join(f'0x{byte:02x}' for byte in bytes.fromhex(hex_inst)[::-1])

# Use llvm-mc to disassemble the binary instruction
result = subprocess.run(
Expand Down

0 comments on commit b97cc73

Please sign in to comment.