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?
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 symbol sym
. It's no different to the machine from something like lui t0, 0xabcde
, just that the assembler is computing the value of the immediate for you.
lui
encodes a 20-bit immediate, so lui t0, %hi(sym)
is one single instruction, not a pseudo-instruction.