how to use ljmp in gcc with indirect address??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Unknown

how to use ljmp in gcc with indirect address??

Post 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!!!
nullify

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

Post 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.
still Unknown

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

Post 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)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

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

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

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

Post 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.
Post Reply