rendered paste body;
; © 2006 XOWare. All Rights Reserved.
; This software is not redistributable in source form without
; explicit permission. For more information about the terms
; and conditions the use and or distribution of this software
; entails, please refer to the complete license located in
; this project's source folder: "Source/License.html".
;
; Module: Boot Sequence
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Constants.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
STACK equ 0x40000
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Multiboot header.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
MultibootHeader:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 32-bit kernel startup code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[section .text]
[bits 32]
[extern LoadMBI] ; externed D function in BootProcess
[global _start] ; entry point defined in linker script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; entry point
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_start:
cli ; disable interrupts (should already be but ensure)
mov [stack + STACK], ESP ; Initialize stack pointer
lgdt [GDTPointer] ; store the gdt_pointer in GDTR
mov AX, 0x10 ; re-set the segment registers
mov DS, AX
mov ES, AX
mov FS, AX
mov GS, AX
mov SS, AX
jmp 0x08:.relocated ; jump to the new code segment (0x08 = GDT offset)
.relocated:
push EBX ; Push MultibootInfo onto stack
push EAX ; Push magic value
call LoadMBI ; load Kernel with multiboot info
hlt ; stop the CPU until an interrupt
jmp $ ; freeze
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[section .data]
GDT:
dd 0x00000000 ; null descriptor
dd 0x00000000 ; -
dd 0x0000FFFF ; kernel code descriptor
dd 0x00CF9A00 ; -
dd 0x0000FFFF ; kernel data descriptor
dd 0x00CF9200 ; -
GDTPointer:
dw 0x17 ; gdt limit [(3 * sizeof(GDTDescriptor)) - 1]
dd GDT ; gdt base address
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[section .bss]
stack:
resd STACK