mortbopet / Ripes

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

lui does not check for valid immediate range #258

Open kediarajesh opened 1 year ago

kediarajesh commented 1 year ago

Hello, I am using v2.2.4 and v2.2.5. While most of the immediate instructions (addi, srli, etc.) check for the immediate value to be within the allowed range, the lui instruction does not check for the same. lui supports only 20-bit of immediate values. If we specify a larger range, the last 20-bits are only considered with extra bits being ignored. It would be rather better to display such instances as error so that any inadvertent typing mistakes are detected early.

Example: lui x9, 0x123456 will get used as lui x9, 0x23456

Regards, Rajesh

mortbopet commented 1 year ago

Can confirm that this indeed is a bug. At first glance, this seems to be related to width-checking logic in instruction.h not handling truncated integers correctly.