Author Topic: question about ljmp  (Read 10588 times)

Offline horse_river

  • Jr. Member
  • *
  • Posts: 9
question about ljmp
« 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?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: question about ljmp
« Reply #1 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




Offline horse_river

  • Jr. Member
  • *
  • Posts: 9
Re: question about ljmp
« Reply #2 on: September 23, 2012, 11:49:28 AM »
so  the  segment  descriptor  is  at  gdt+x  or  not ?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: question about ljmp
« Reply #3 on: September 23, 2012, 04:57:42 PM »
Yeah, should be. I think...

Best,
Frank


Offline horse_river

  • Jr. Member
  • *
  • Posts: 9
Re: question about ljmp
« Reply #4 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 !