Created
February 10, 2020 23:38
-
-
Save halferty/267b30874a5253a20b9cc5ee2fd99175 to your computer and use it in GitHub Desktop.
Disassembles a single RISCV opcode in hex string format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# opcode = "00162023" | |
opcode = ARGV[0] | |
`echo ".text;.word 0x#{opcode}" > ~/tmp/test.S` | |
`$RISCV/bin/*gcc -c ~/tmp/test.S -o ~/tmp/test.o 2> /dev/null` | |
res = `$RISCV/bin/*objdump -d ~/tmp/test.o 2> /dev/null` | |
puts res.split(/\n/).last.split(/\t/)[2..-1].join(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment