Clear all

Disassembler And Wrong Program Counter


New Member
Joined: 1 year ago
Posts: 3
Topic starter  


The RISC-V Disassembly is wrong for the AL_Operations.S

It disassembles to machine codes of either 16bits or 32bits and it is not correct. (See attached image)

00000090 <main>:
90: 4e01 li t3,0

00000092 <REPEAT>:
92: 0e19 addi t3,t3,6
94: 1e7d addi t3,t3,-1
96: 003e7e13 andi t3,t3,3
9a: fe000ce3 beqz zero,92 <REPEAT>
9e: 0001 nop

li t3, 0x0                  # t3 = 0


    addi t3, t3, 6          # t3 = t3 + 6
    addi t3, t3, -1         # t3 = t3 - 1
    andi t3, t3, 3          # t3 = t3 AND 3
    beq  zero, zero, REPEAT # Repeat the loop

As a result, the Program Counter is also showing incorrect values. ex: It goes as 90 -> 92 -> 94 -> 9a and back to Repeat at 92. But
Now I am wondering the debugging is trustworthy at all?

The correct disassembly should be:


Is there any solution?


Thank you and best regards,

This topic was modified 1 year ago by hachat

Member Admin
Joined: 3 years ago
Posts: 64

Hi @hachat,

The SweRV EH1 processor includes the RISC-V Compressed Extension ( In this program you can find a mix of compressed (16-bit)
and 32-bit instructions (note that not all instructions have a compressed version and that the compressed extension allows 16-bit instructions to be freely intermixed with 32-bit instructions). By default, compressed instructions are enabled in RVfpga; if you want to disable their use, you can follow the steps described in Section 2.B of the RVfpga/Labs/Lab11/RVfpga_SweRVref document (you can find an example of a program that disables the use of compressed instructions at: RVfpga/Labs/Lab11/ExampleProgram). In SweRV EH1 the Align Stage translates the compressed instructions into the corresponding 32-bit version before providing them to the Decode Stage (you can find more explanations in Lab 11). It can be useful for you to perform the Verilator Simulation of the AL_Operations program, shown in Section 7 of the GSG (note that in the simulation the instructions are shown in the Decode Stage, where they have already been translated into the 32-bit version).

If you have more questions. please let us know.

Best regards


RCWO reacted
New Member
Joined: 1 year ago
Posts: 3
Topic starter  


Great! Thank you very much Dani.  Its very clear now, and learned a lot right there! That was really helpful and informative.

Best Regards,




RCWO reacted