Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think there's an error in the Position Independence section:

    start:
        auipc a0, 3
        addi a0, a0, 4
The text says that this should result in 0x3004; was this example intended to be

    start:
        lui a0, 3
        addi a0, a0, 4


No, because `lui` results in an absolute address, not a position independent one.

The `auipc/addi` sequence results in 0x3004 + whatever the address of the `auipc` instruction itself is. If the `auipc` is at address 0 then the result will be the same.


Exactly, but the text has the same instruction sequence twice and the parent correctly indicated that the first copy should have used "lui" to illustrate the problem you mentioned and the second copy does use "auipc" to illustrate the fix you mentioned.


Oh, fair enough.


This copypasta has been fixed.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: