Page 1 of 1

how to use ljmp in gcc with indirect address??

Posted: Sat Nov 15, 2003 9:03 am
by Unknown
I want to make a task switch in my os, the selector for the TSS is in a int "selector". I tryed the following methods:

1. asm("ljmp *(_selector)");

2. asm(".intel_syntax");
asm("ljmp _selector");
asm("att_syntax");

When i disassamble with ndisasm it shows:

jmp far [0x12757]

what i want is of course jmp far 0x12757 (0x12757 is the address to selector).

How to do this?? Please HELP!!!

Re:how to use ljmp in gcc with indirect address??

Posted: Sat Nov 15, 2003 1:59 pm
by nullify
I think LJMP requires two operands: one for the code selector, and one for the offset address. In your case, the offset address would be zero.

Re:how to use ljmp in gcc with indirect address??

Posted: Sat Nov 15, 2003 5:58 pm
by still Unknown
Yes, on a direct jump, but i want to make a indirect jump, so i should specify a memory location wich contains the seg:offset pair.... (offset is ignored when jumping to a TSS they write in the Intel manual)

Re:how to use ljmp in gcc with indirect address??

Posted: Mon Nov 17, 2003 4:04 am
by Candy
still Unknown wrote: Yes, on a direct jump, but i want to make a indirect jump, so i should specify a memory location wich contains the seg:offset pair.... (offset is ignored when jumping to a TSS they write in the Intel manual)
even though it is ignored, you must still specify it.

Re:how to use ljmp in gcc with indirect address??

Posted: Mon Nov 17, 2003 6:37 am
by Pype.Clicker
<intel syntax>

Code: Select all

jmp far 0x1234:0x5678abcd
loads CS with 0x1234 and eip with 0x5678abcd.

Code: Select all

 jmp far [0x12345678]
looks up a dword:word memory location and loads CS with the word located at 0x12345678+4 and eip with the dword located at 0x12345678 ...

Check intel manual volume 2 for more info.