NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: ben321 on January 28, 2019, 05:21:12 AM

Title: Question about far jumps
Post by: ben321 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.
Title: Re: Question about far jumps
Post by: Frank Kotler 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

Title: Re: Question about far jumps
Post by: fredericopissarra 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...