1

I can't get full grip on specifics of far/near versions of jmp/call. As I understand near jmp/call instructions use relative offset from instruction itself as operand. Far jmp/call instructions use absolute address as operand.

1) In protected mode this absolute address is just virtual address placed by the compiler.
2) In real mode you usually write:

jmp [new number of code segment][proc name as offset]

then absolute address is computed by formula:

address = new number * 10h + offset

which is really physical address in real mode.

Does CPU automatically update CS when performing far jmp/call? For example when BIOS code jumps to loaded boot sector code. I don't see setting CS value in source code of boot sector file.

In protected mode: cs = index in descriptor table = absolute address / page size
In real mode: cs = segment index in RAM = specified "new number of code segment"

Are my assumptions correct?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
igntec
  • 1,006
  • 10
  • 24

1 Answers1

3

Yes, the far jump/call updates CS of course.

In protected mode, the segment selector refers to an entry in a table, namely the GDT (global descriptor table) or the LDT (local descriptor table) depending on the value of bit #2. Said descriptor entry holds the base address and the limit for the segment.

This is all described in detail in the intel manuals.

Jester
  • 56,577
  • 4
  • 81
  • 125