Is there a set format on how immediates are shown in RISC-V assembly?

53 views Asked by At

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?

1

There are 1 answers

0
Nate Eldredge On BEST ANSWER

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.