Author Topic: Question about far jumps  (Read 9386 times)

Offline ben321

  • Full Member
  • **
  • Posts: 185
Question about far jumps
« on: January 28, 2019, 05:21:12 AM »
What is the difference between "JMP [FS:0]" and "JMP FAR [FS:0]"?
I notice both of these compile in NASM, but generate different opcodes. I assumed they would be the same, because by definition, a far jump is any jump that changes the segment that the code is executing in. CS:0 is not the same location in memory as FS:0, because even though the offset is 0 in both cases, the segment is different.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Question about far jumps
« Reply #1 on: January 28, 2019, 05:57:11 AM »
Hi ben321,

In the code you show, fs:0 is not the target of the jump. It is the location in memory where the target of the jump is found. far jumps are mostly used in 16 bit code... and it usually doesn't use fs. If you are seeing:
Code: [Select]
jmp far [fs:0]
please show us where. It seems very unusual to me.

Best,
Frank


Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: Question about far jumps
« Reply #2 on: January 30, 2019, 07:23:37 PM »
Near indirect jumps use only the offset portion of selector:offset pair, so, in 32 bits jmp [ptr] will get 32 bits on ptr location to use as offset and will use the current CS.

Far indirect jumps will get 8 bytes to for the selector:offset pair.

Of course this is a little bit differnt on 16 or 64 bits modes...