mortbopet / Ripes

A graphical processor simulator and assembly editor for the RISC-V ISA
https://ripes.me/
MIT License
2.57k stars 274 forks source link

Fix offset of compressed instructions c.bnez and c.beqz #195

Closed lcgamboa closed 2 years ago

lcgamboa commented 2 years ago

This PR fixes a bug in decoding the compressed instructions c.bnez and c.beqz.

mortbopet commented 2 years ago

Great find! Would you mind adding tests in https://github.com/mortbopet/Ripes/blob/master/test/riscv-tests-c/rvc.s which captures the issues?

lcgamboa commented 2 years ago

Great find! Would you mind adding tests in https://github.com/mortbopet/Ripes/blob/master/test/riscv-tests-c/rvc.s which captures the issues?

To test these instructions, is needed to make big jumps backward and forward, to test the limits of arguments. For example c.bnez x15, 255 and c.bnez x15, -255. Do you know any way to do this without having to use a bunch of nop instructions to fill in addresses between jumps?

mortbopet commented 2 years ago

One way is to use the .zero directive inside the .text segment: image