On Apr 26, 7:25 am, "Helge Kruse" <spamt...@[EMAIL PROTECTED]
> wrote:
> Hello,
>
> I wrote a x86 boot loader a long time ago. One step is to jump form 16
bit to 32 bit segment before entering protected mode.
That's not possible, unless you mean "completing the pmode setup" by
"entering". Flipping CR0.PE does the mode switch, but it's not
complete.
> I found
> that I need the opcode
>
> _BOOT SEGMENT PARA USE16 PUBLIC 'ZZZZ_LINK_REALLY_LAST'
>
> 00000076 66 db 66h ;----- jmpf cs:pInitCpuFlush -----
> 00000077 2E db 2Eh ; CS:
> 00000078 FF 2E db 0FFh, 2Eh ; JMPF
> 0000007A 0000001E R dd OFFSET pInitCpuFlush
>
> _INIT SEGMENT PARA USE32 PUBLIC 'ZZZ_LINK_AT_LAST'
>
> 0000001E pInitCpuFlush LABEL FWORD
> 0000001E 000000FC R dd EnterProtMode
> 00000022 0010 dw GdtCode - GdtNull
>
> That works. When I try to encode this with normal instructions I get
different opcodes:
>
> jmp cs:pInitCpuFlush
>
> 0000007E 67& 66| 2E: FF jmp cs:pInitCpuFlush
> 2D 0000001E R
> 00000087 67& 66| FF 2D jmp pInitCpuFlush
> 0000001E R
> 0000008F 67& 66| 2E: FF jmp fword ptr cs:pInitCpuFlush
> 2D 0000001E R
> 00000098 _BOOT ENDS
>
> Is there any way to write a clean jump to 32 bit segment?
>
> /Helge
I don't know what you mean by clean jump. Are you asking how to write
this jump w/o using db or something else?
I usually use one of the following:
- JMP Ap: opcode 0xEA followed by immediate far pointer
- PUSH selector, PUSH offset, RETF
Alex


|