jmp far, PMode

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
Thomas

jmp far, PMode

Post by Thomas »

Hello,
how can i jump (in pmode) to another codesegment?
I load a binary file to 0x70000. The Code and Datasegments are set up well. When i tell gas to
jmp $48, 0 (48 = selector for the files codeseg) my pc resets.
(before this i set of course ds)
also
pushw $48
pushl $0
retf doent work.
asdf

Re: jmp far, PMode

Post by asdf »

>The Code and Datasegments are set up well. When i tell gas >to
>  jmp $48, 0 (48 = selector for the files codeseg) my pc >resets.

the assembler that comes with DJGPP chokes on that instruction, are you sure the syntax is correct?

is the base address of the code segment descriptor set to 0x70000 ?

you can poke characters into video memory as you switch to pmode and jump to the kernel, to see how far the code gets
Thomas

Re: jmp far, PMode

Post by Thomas »

i AM allready in PMode! i also tried a nasm function

global _test
test:
jmp 48:0

->effekt: the pc resets
Im_VLAVI

Re: jmp far, PMode

Post by Im_VLAVI »

I 've made my bootsector with GAS too, in LINUX. Two things:

1) I load my kernel at 0x9000 and switch to PM. To make far jumps I use machines code directly:

.byte 0xea  #opcode for jump
.int 0x9000,0x10 # offset and sector descriptor in GDT

NOTE: notice the .int, in PM we use 32 bits. In RM we use 16 bits and after lgdt, you have to use:
 .byte 0xea
 .word offset,segment_descriptor # .word -> 16 bits

2) What you have to achieve is this machine code with your compiler (GAS). In GAS you have to use ljmp/lcall $SECTION,$OFFSET for far jumps/calls.

I hope this will help you.

VLAVI,
Thomas

Re: jmp far, PMode

Post by Thomas »

I did it. I made 2 Task State Segments (TSS) and load the Taskregister. Then i just jumped to the TSS-Selector.
Theres another problem:
When i load a binary file assembled with nasm everything is fine. If i load another file, compiled with gcc and linked to binary fileformat (all it does is: while(1);!!) the pc resets?!?!
i just say: wonderfull world of protected mode and OSD with a compiler *g*.
Cryst

Re: jmp far, PMode

Post by Cryst »

Assemblers mess up alot, its best to hard code pointers into the code
i.e.
(i don't know GAS sentax so bear with me)
Byte  0EAh
DWord Offset
Word Segment

when the program gets to this point it will execute an absolute jump (EA) to Segment:Offset and your problem should be solved, but if you dont set segment and Offset correctly you will still crash.
Post Reply