Re: "Real Mode is required primarily to set up the processor for Protected Mode operation."
- From: Eric <nospam@xxxxxxxxx>
- Date: Wed, 26 Oct 2005 23:34:06 -0700
look and see wrote:
> -- The Intel386 SX MicroProcessor manual, page 6.
>
> The following is a code snippet from the "Hello, Dawn!" 32 bit protected
> mode boot sector written in Nasm assembly language.
>
> bits 16
> org 7C00h
>
> Protected mode requires a minimum Global Descriptor Table. Each entry is
> eight bytes, the first is the NULL descriptor, the content of which can be
> anything. In this case it begins with the required jump instruction which
> makes a boot sector bootable. This is followed by size of the table minus
> one, and following that is the pointer to the table. The second entry is
> the Code Descriptor, which is mapped to the entire 4 gigabyte address
> space. The third entry is the Data Descriptor, which is also mapped to the
> entire address space.
>
> gdt:
> jmp short real_mode_entry
> dw 23
> dd gdt
> dw 0FFFFh, 0, 9A00h, 0CFh
> dw 0FFFFh, 0, 9200h, 0CFh
>
> The Global Descriptor Table register is loaded with the values at gdt+2
> and the cr0 register bit 0 is set to one to enable Protected Mode. A far
> jump using the GDT Code Descriptor at table offset eight is made to the
> next instruction to clear the Pre-fetch Queue.
>
> real_mode_entry:
> lgdt [cs:gdt+2]
> mov eax, 1
> mov cr0, eax
> jmp 8:protected_mode_entry
>
> This is the 32 bit Protected Mode entry point.
>
> bits 32
> protected_mode_entry:
>
> The interrupt flag is cleared to disable the maskable hardware interrupts.
> The Data and Stack Segment registers are loaded with the GDT Data
> Descriptor at table offset sixteen and the Stack Pointer is loaded with
> the top of low memory.
>
> cli
> mov eax, 16
> mov ds, ax
> mov ss, ax
> mov esp, 0A0000h
>
> Sending 0Ch to the Digital Output Register of the Floppy Disk Controller
> at port 3F2h turns off the floppy disk motor.
>
> mov edx, 3F2h
> mov al, 0Ch
> out dx, al
>
> To be continued ...
>
> "Hello, Dawn!" is a 32 bit protected mode boot sector using no bios calls.
> The boot sector image is available at
> http://mikegonta.com/HelloDawn/BOOTIMG.BIN
>
> Copyright 2005
>
> Mike Gonta
> look and see - many look but few see
What? no source?
.
- Prev by Date: Re: HLA v1.78 is now available
- Next by Date: Re: HLA v1.78 is now available
- Previous by thread: exp(300)
- Next by thread: Real Mode
- Index(es):