Page 1 of 1
relative addressing
Posted: Sat Apr 10, 2004 2:29 pm
by mike25025
how does one do this?
i tried the use eip but nasm says that its undefined
can someone help me?
i need 32 pmode
Re:relative addressing
Posted: Sat Apr 10, 2004 2:46 pm
by Candy
mike25025 wrote:
how does one do this?
i tried the use eip but nasm says that its undefined
can someone help me?
i need 32 pmode
32-bit x86 processors have no eip relative adressing except for jumps (where it is required and thus implicit). Only x86-64 and up have IP relative, although it's RIP relative there.
for a usable reply, to get to pmode, try the methods outlined in numerous online manuals, the Intel manual, the AMD manual, hundreds of free operating systems and lots of other programs that are free & use pmode. You have so much reference, there's no reason to ask such a general question. Also, did you try the OSFAQ?
http://www.osdev.org/osfaq2/
Re:relative addressing
Posted: Sat Apr 10, 2004 2:50 pm
by mike25025
but how do i gat data relatively?
Re:relative addressing
Posted: Sat Apr 10, 2004 2:54 pm
by Candy
mike25025 wrote:
but how do i gat data relatively?
by using -fPIC or by manually abusing a register as a code location base register
Why do you want a relative pointer to data?
Re:relative addressing
Posted: Sat Apr 10, 2004 2:59 pm
by mike25025
is because of the design of my os
it cant guarantee that a program is in a specific address (even in vm)
one more thing
how many registers does c++ use
Re:relative addressing
Posted: Sun Apr 11, 2004 1:38 am
by Candy
mike25025 wrote:
is because of the design of my os
it cant guarantee that a program is in a specific address (even in vm)
Uhm... consider looking up the idea behind Relocation, or check out the Procedure Linkage Table or the Global Offset Table (PLT / GOT). Using PIC on x86 pre-64bit is slow, because you waste a register.
one more thing
how many registers does c++ use
all that are available, obviously. If you want to know how and why it preserves or wrecks registers, read the Application Binary Interfaces (ABI's) for each of the processors. They explain what you have to preserve, what's yours etc.