I'm working on parsing RISC-V assembly, and am working on parsing immediates. Using the LUI
instruction as an example, I'm seeing examples which write it like lui t0, 0
, and examples which write it like lui t0,%hi(string1)
. Is the 2nd example a psudeoinstruction, and is there any documentation on how each notation works?
Is there a set format on how immediates are shown in RISC-V assembly?
53 views Asked by UnicornsOnLSD At
1
You can find documentation for modifiers like
%hi
in the GNU assembler manual.%hi(sym)
evaluates to the high 20 bits of the address of the symbolsym
. It's no different to the machine from something likelui t0, 0xabcde
, just that the assembler is computing the value of the immediate for you.lui
encodes a 20-bit immediate, solui t0, %hi(sym)
is one single instruction, not a pseudo-instruction.