NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: horse_river on September 23, 2012, 07:09:39 AM
-
hi.
ljmp *memaddr
in the memaddr , there is a segment selector and offset , if the selector is x, the segment descriptor is gdt
i want to know how does cpu use x to address the segment descriptor ?
thanks?
-
Well... x should be a multiple of 8, and it serves as an index into the gdt. The instruction puts the selector (x) into cs, and the offset into eip (rip?). The "base" from the indexed descriptor is added to the offset to form a linear address, and it goes there. See the Intel/AMD manuals for details. We still in the Linux bootcode? There must be documentation for that(?)...
Best,
Frank
-
so the segment descriptor is at gdt+x or not ?
-
Yeah, should be. I think...
Best,
Frank
-
this is the task switch code :
calculate the task descriptor of task n , FIRST_TSS_ENTRY is 4
#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3))
I can not understand why n<<4 and FIRST_TSS_ENTRY<<3
can you interprete it ?
thanks !