Re:i386 Assembly Language trick for storing data in .text
by higherhalf on Thursday November 09, 2023 @11:34AM
(#38207185)
This can be done even simpler:
For NASM, it can also be put into a macro, for example printing to video memory at 0xb8000:
[ Parent
| on HN ]
Re:i386 Assembly Language trick for storing data in .text
by projektfu on Thursday November 09, 2023 @11:45AM
(#38207352)
That will require a fixup or a fixed load address. The example in the article is position independent.
Re:i386 Assembly Language trick for storing data in .text
by fargle on Thursday November 09, 2023 @11:50AM
(#38207423)
the author wanted it to be position-independent (PIC), so it works no matter what address the .text segment is loaded to and run.
This example uses a fixed symbolic reference ("string:") and is the normal way to do it. The trick is to it in a PC relative way.