NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: horse_river on September 23, 2012, 07:09:39 AM

Title: question about ljmp
Post 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?
Title: Re: question about ljmp
Post by: Frank Kotler on September 23, 2012, 10:30:49 AM
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



Title: Re: question about ljmp
Post by: horse_river on September 23, 2012, 11:49:28 AM
so  the  segment  descriptor  is  at  gdt+x  or  not ?
Title: Re: question about ljmp
Post by: Frank Kotler on September 23, 2012, 04:57:42 PM
Yeah, should be. I think...

Best,
Frank

Title: Re: question about ljmp
Post by: horse_river on September 24, 2012, 12:34:55 PM
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 !