Page 1 of 1

real mode to long mode in wiki

Posted: Tue May 17, 2011 6:04 am
by nicola
hi guys,
i followed the sample in osdev wiki at
http://wiki.osdev.org/Entering_Long_Mode_Directly

but got stuck in this line (cant compile)

Code: Select all

;Enter long mode

mov eax,10100000b				;Set PAE and PGE
mov cr4,eax

mov edx, 0x0000a000				;Point CR3 at PML4
mov cr3,edx

mov ecx,0xC0000080				;Specify EFER MSR

rdmsr						;Enable Long Mode
or eax,0x00000100
wrmsr

mov ebx,cr0					;Activate long mode
or ebx,0x80000001				;by enabling paging and protection simultaneously
mov cr0,ebx					;skipping protected mode entirely

lgdt [gdt.pointer]				;load 80-bit gdt.pointer below

jmp gdt.code:startLongMode			;Load CS with 64 bit segment and flush the instruction cache



;Global Descriptor Table
gdt:
dq 0x0000000000000000				;Null Descriptor

.code equ $ - gdt
dq 0x0020980000000000                   

.data equ $ - gdt
dq 0x0000900000000000                   

.pointer:
dw $-gdt-1					;16-bit Size (Limit)
dq gdt
i'm using flat assembler and it say the line

Code: Select all

jmp gdt.code:startLongMode
has unknown symbol "gdt.code"

but it is clearly declared in Global Descriptor Table above.

and i wonder why gdt.pointer is known
and gdt.code is unknown

please help

Re: real mode to long mode in wiki

Posted: Tue May 17, 2011 7:52 am
by Combuster
The wiki wrote:NASM code
You wrote:i'm using flat assembler
Use the right tool for the job :wink:

Re: real mode to long mode in wiki

Posted: Wed May 18, 2011 6:14 am
by nicola
ok combuster,
now i'm using NASM

i copied exactly the source from http://wiki.osdev.org/Entering_Long_Mode_Directly
after assembling, i got 624 bytes
i then booted it as a floppy using Bochs, but the line "Put long mode kernel here.__" didn't appear
as quoted in the wiki article

nothing but the blinking cursor
is that wiki article reliable?

Re: real mode to long mode in wiki

Posted: Wed May 18, 2011 6:44 am
by nicola
:oops: my apology
the code runs fine, but it did not clear screen before writing
out "Put long mode kernel here.__" so i thought it hanged :P