NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: florian on September 01, 2011, 08:00:49 PM

Title: relative calls
Post by: florian on September 01, 2011, 08:00:49 PM
Hi
I was wondering how to use relative calls.
If I assemble this:
Code: [Select]
section .text
global _main
_main:
mov eax, 2
call xy
xy:
pop eax
It gets translated with a fixed address:
Code: [Select]
00000000  66B802000000      mov eax,0x2
00000006  E80000            call word 0x9
00000009  6658              pop eax
Title: Re: relative calls
Post by: Frank Kotler on September 01, 2011, 08:15:26 PM
We write "call xy", and it gets disassembled as "call (address of) xy", but if you look at the actual encoding, it's "call" (e8) distance (plus or minus) to xy (0000, in this case).

Best,
Frank

Title: Re: relative calls
Post by: florian on September 01, 2011, 08:24:01 PM
Hmmm so I actualy already got what I wanted and I was just to stupid to see it :D

thank you for your help anyway :)
Title: Re: relative calls
Post by: Frank Kotler on September 01, 2011, 08:34:25 PM
It's not an obvious thing!

Best,
Frank