[SOLVED] RISC-V Assembler : why are hex literals illegal?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] RISC-V Assembler : why are hex literals illegal?

    New

    I'm trying to include some assembler code in a RISC-V project and am running into some weirdness. Hex literals are not working with an "add immediate" (addi), but base ten and binary literals do. Here are a few lines:

    Source Code

    1. li t0,0b000100; // this works.
    2. li t0,0xFACE; // this works
    3. addi t0,x0,0b0001; // this works
    4. addi t1,x0,0xFACE; // this DOES NOT work. (hex for addi)
    5. addi x5,x0,1234; // this works

    Not sure why that would be the case... any thoughts as to what I might be doing wrong?James
    Images
    • Screenshot 2025-02-03 at 9.29.55 PM.png

      416.1 kB, 1,744×952, viewed 34 times
  • New

    Never mind... my mistake...

    it's not that the hex literal is illegal... it's that it's too large... forgot that there are a limited number of bits permitted with the addi operation... and that li is a pseudo-operation that gets expanded into a lui and addi to permit larger literals to be loaded into a register by breaking it up into two separate operations.

    Doh.