12/18/2025
RISC-V hexdump program
I wrote a small program in Risc-V that does a hex dump similarly to the one in chastehex. This is not the full chastehex program but it at least mimics the hexdump feature perfectly. Here is a screenshot of it working. Source Code for RISC-V emulator: rars .data title: .asciz "hexdump program in RISC-V assembly language\n\n" # test string of integer for input test_int: .asciz "10011101001110011110011" hex_message: .asciz "Hex Dump of File: " file_message_yes: "The file is open.\n" file_message_no: "The file could not be opened.\n" file_data: .byte '?':16 .byte 0 space_three: .asciz " " is the location in memory where digits are written to by the putint function int_string: .byte '?':32 int_newline: .byte 10,0 radix: .byte 2 int_width: .byte 4 argc: .word 0 argv: .word 0 .text main: # at the beginning of the program a0 has the number of arguments # so we will save it in the argc variable la t1,argc sw a0,0(t1) # at the beginning of the program a1 has a pointer to the argument strings # so we save it because we may need a1 for system calls la t1,argv sw a1,0(t1) that the argument data is stored away, we can access it even if it is overwritten....
I wrote a small program in Risc-V that does a hex dump similarly to the one in chastehex. This is not the full chastehex program but it at least mimics the hexdump feature perfectly. Here is a scre…