Author Topic: Help understanding "offsets" and "relative addressing"  (Read 3937 times)

Offline turtle13

  • Jr. Member
  • *
  • Posts: 73
Help understanding "offsets" and "relative addressing"
« on: September 07, 2018, 02:59:21 AM »
I am having a hard time finding info. online about relative addressing. I am studying Intel 64- bit assembly and am reading up in the Intel manual vol1. I came across this:

"The destination operand is a relative address (that is, an offset relative to the contents of the EIP register)"

Can somebody plz describe what is a relative address/ offset in this case? Maybe with some example addresses of what is going on.

Offline dreamCoder

  • Full Member
  • **
  • Posts: 107
Re: Help understanding "offsets" and "relative addressing"
« Reply #1 on: September 07, 2018, 07:42:23 AM »
It means exactly as it says... how far is the position, in bytes, of an item currently being referenced, from the current RIP register (after the next instruction because RIP points to the next instruction). For example;

0x400100   call myTestFunction   ;by this time RIP points to 0x400107 (next instruction)
0x400107   nop
0x400108   nop
0x400109   myTestFunction:

Therefore the encoding for call myTestFunction should be E8 02 00 00 00 because it is located two bytes off the next instruction (the first nop). This is just a pseudo example.