Is there a way to make MARS or RARS disassemble an instruction given in hex?

210 views Asked by At

MARS & RARS contain a disassembler, but

  1. don't allow .word within .text
  2. will only disassemble the .text section

Is there a way to get these simulators to disassemble an instruction from hex?

(The common online disassemblers also don't support RISC V!)

1

There are 1 answers

3
Erik Eidt On BEST ANSWER

The following code sequence will make RARS/MARS disassemble from hex (RARS version here).  The program can be edited to use other instructions as hex, and, after running the program, disassembly can be seen in the "Text Segment" column "Basic".  The option for "Self-modifying code" must be enabled in the "Settings" menu.

    .data
WStart: 
    .word 0x00052283     # as many instructions in hex or other here as will fit in the nop's below
    .word 0xfae7d2e3
WEnd:
    .text
main:
    j next
CC0:                # after running the program,
    nop             # find disassembly here in the "Basic" column of the "Text Segment" window
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
next:
    la a0, WStart
    la a1, WEnd
    la a2, CC0
loop1:
    lw t0, (a0)
    sw t0, (a2)
    addi a0, a0, 4
    addi a2, a2, 4
    bne a0, a1, loop1
    
    li a7, 10
    ecall

enter image description here