So then apart from going in and out of Protected mode. Why would you ever use far jmps/calls? In usermode I cann't find a reason?
In 16-bit Windows applications, there are many segments, each based at different addresses, and far calls are used a lot. OS/2 also uses different code segments. I also have some far jumps in a Mac OS X emulator I'm working on, where I need to have a value in CS that is different from 1bh so that Windows will leave my GS register alone, but the other code segment I'm setting up is the same as the default one.
Is not going to call the fix address 0x8050404 but the relative address. I am alittle confused on the difference if the .text section is taken to be = offset 0 then won't relative and physical corrospond provided the os loads the code in the exact location it should with no reloc needed????
No, only the immediate forms of jmp and call are relative. All jumps and calls using register or memory operands are absolute, and with call eax the next instruction to execute will be the one whose address is in eax. When a relative address is used, the operand is added to the address of the byte directly following the instruction. For example, an instruction that jumps to itself would be EB FE or E9 FB FF FF FF (the first one is a short jump, which uses a signed byte as the relative address).
Instructions do not use physical addresses directly. Memory operands are specified by an offset within a segment, which are added to the segment base to produce a virtual address. This is also true of relative calls and jumps, here the operand is added to the offset of the next instruction to produce the target offset, which is loaded into EIP. EIP and the CS base together determine the virtual address of the next instruction. The GDTR and IDTR registers contain virtual addresses. The CR3 register, the page directory and the page tables are the only places where physical addresses are used. However, when paging is disabled, physical addresses equal virtual addresses.
It seems if RETF is only doing the extra poping of cs off the stack then ret 2 should be the same thing.
Call far and retf always use 4 bytes for CS in 32 bit mode. It's not the same thing if CS changes. With RETF, CS is restored, but with RET 4, it is not.