there´s another way to change the cs selector

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
blito

there´s another way to change the cs selector

Post by blito »

Hello!!!!.
i´m entering protected mode and y set up the
data selector in ds,fs,gs,ss
now i have to change the cs from 0x5000 (real mode segment)
to 0x8 (the protected mode code selector)
i know that with a far jmp i can change the cs value
there´s another way to do this?
J. Weeks

RE:there´s another way to change the cs selector

Post by J. Weeks »

>On 2002-04-17 14:16:34, blito wrote:
>Hello!!!!.
>i´m entering protected mode and y set up the
>data selector in ds,fs,gs,ss
>now i have to change the cs from 0x5000 (real mode segment)
>to 0x8 (the protected mode code selector)
>i know that with a far jmp i can change the cs value
>there´s another way to do this?

Why would you want to do it another way? Any reason
why a far jump isn't acceptable?

You can try this:
push 0x08
pop cs

I don't know if it'll work... it might. I don't
remember my opcodes too well anymore :)

Jeff
Chris Giese

RE:there´s another way to change the cs selector

Post by Chris Giese »

>On 2002-04-17 14:16:34, blito wrote:
>Hello!!!!.
>i´m entering protected mode and y set up the
>data selector in ds,fs,gs,ss
>now i have to change the cs from 0x5000 (real mode segment)
>to 0x8 (the protected mode code selector)
>i know that with a far jmp i can change the cs value
>there´s another way to do this?

Use RETF

BITS 16

push PMODE_CS
push dword pmode_eip
o32 retf

Did your bootloader stack and data segment
"disappear" after you loaded SS and DS?
This is not surprising :)

If you want to jump to a variable address,
you can still do what you're doing, but use
self-modifying code:

BITS 16

mov [entry + 2],eax ; EAX=pmode_eip
; ...enable A20 here, if necessary
; ...fix up GDT and gdt_ptr here
cli
lgdt [gdt_ptr]
mov ax,PMODE_DS
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,pmode_esp
entry:
jmp PMODE_CS:dword 0
Kernel Panic

RE:there´s

Post by Kernel Panic »

>On 2002-04-18 10:34:53, J. Weeks wrote:
>You can try this:
>push 0x08
>pop cs
No, it won't work :) . It would only work on an 8088 (and, perhaps, an 8086; well.. even on a 186 =) ). But the "pop cs" opcode is 0x0F, and it has absolutely other meaning in every processor from 286 and further, as you know =) .
Post Reply