flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Getting into Protected Mode [AMD64]

Author
Thread Post new topic Reply to topic
SouthernMunk



Joined: 05 Aug 2005
Posts: 6
SouthernMunk 06 Aug 2005, 06:36
AMD's System Programmer's Guide says that the only steps required to enter protected mode are:

1) Set up the GDT
2) Set up the IDT and ISRs
3) Set the PE (Protection Enabled) bit of CR0.

Is this correct? I don't think they mention anything about the A20 address line at all.
Post 06 Aug 2005, 06:36
View user's profile Send private message Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 06 Aug 2005, 07:47
As far as I know setting up a IDT isn't realy required. There's another step not required by the CPU directly, reprogramming the PIC. Else you'll get all the IRQs in exceptions...
Post 06 Aug 2005, 07:47
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 06 Aug 2005, 11:21
You do not need A20 to go to pmode, but you will not be able to use the full 4GB of memory,
Code:
org 0x7C00use16;****************************; Realmode startup code.;****************************start:        xor   ax,ax        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   sp,0x7C00;*****************************; Setting up, to enter pmode.;*****************************        cli         lgdt  [gdtr]                mov   eax, cr0        or    al,0x1         mov   cr0,eax        jmp   0x10: protected;*****************************; Pmode. Wink;*****************************use32protected:        mov   ax,0x8        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   esp,0x7C00;*****************************; Turn floppy off (if space).;*****************************        mov   dx,3F2h        mov   al,0        out   dx,al        jmp   $ ;*************************************; GDT. ;*************************************gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CFsys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CFgdt_end:gdtr:       dw gdt_end - gdt - 1                                                      dd gdt;*************************************; Make program 510 byte's + 0xaa55;*************************************            times 510- ($-start)  db 0dw 0xaa55    


Th is about the smallist code for go to pmode, you can even take out the turn floppy motor off to make it smaller Wink .
Post 06 Aug 2005, 11:21
View user's profile Send private message Reply with quote
SouthernMunk



Joined: 05 Aug 2005
Posts: 6
SouthernMunk 07 Aug 2005, 00:24
Cool, thanks!

Quote:

You do not need A20 to go to pmode, but you will not be able to use the full 4GB of memory,


So how much memory can you access? Surely more than the 1MB used by Real Mode, as memory addressing is calculated differently.

Because setting up the IDT is not necessary for entering PMode, there's less code required to enter Long Mode! Yay!

Thanks for the responses, guys! Very Happy
Post 07 Aug 2005, 00:24
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 07 Aug 2005, 12:54
Every other MB.
As for long mode this bit of code may help, as it goes to long mode from real mode,
its for yasm not fasm Crying or Very sad


Description:
Download
Filename: 64bit.asm
Filesize: 17.29 KB
Downloaded: 507 Time(s)

Post 07 Aug 2005, 12:54
View user's profile Send private message Reply with quote
Night Rider



Joined: 28 Jul 2005
Posts: 72
Night Rider 07 Aug 2005, 16:21
Quote:

So how much memory can you access

16 Mb
Post 07 Aug 2005, 16:21
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.