relative addressing

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mike25025

relative addressing

Post 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
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:relative addressing

Post 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/
mike25025

Re:relative addressing

Post by mike25025 »

but how do i gat data relatively?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:relative addressing

Post 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?
mike25025

Re:relative addressing

Post 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
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:relative addressing

Post 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.
Post Reply