Reputation: 1
Hi I'm trying to store a number for division purposes but I'm getting this error when I try to assemble the program
"10000": operand is out of range
the code having a problem looks like this
addi t1, zero, 10000
this line of code did work with smaller numbers, with 1-2047 working 2048-4095 giving
Unsigned value is too large to fit into a sign-extended immediate
and numbers greater giving the same error message
Upvotes: 0
Views: 269
Reputation: 53
Immediate values, such as the one you're trying to write to the register file, have a fixed bit-length which is defined by the instruction format. Please see section 2.2 in the official RISC-V spec for a nice diagram.
In RV32I, I-type instructions like addi
have a 12-bit immediate, meaning that they can represent 4096 (2^12). You can always shift bits left and add another value to it to create larger values.
Upvotes: 1