Well.. Here's my bootloader (TASM syntax):
Code: Select all
.model tiny
.code
.8086
_start:
cli ; Disable IRQ until stack is ready
mov ax,07C0h ; Set up ds
mov ds,ax
xor ax,ax ; Set up our stack
mov ss,ax
mov sp,4500h
sti ; IRQ on, Real-Mode stack
mov si,00000000d
mov bx,0800h ; ES = dest.seg.
mov es,bx
xor bx,bx ; BX = dest.offs.
mov ah,2 ; Read function
mov ch,0 ; Cylinder/Track
mov cl,2 ; Start sector
mov al,3 ; Sectors to read (per call)
mov dh,0 ; Head number
mov dl,0 ; Drive number of floppy drive to read from
int 13h ; Read!
cmp byte ptr [es:0000],0E9h
je jcode
cmp byte ptr [es:0000],0EBh
je jcode
_error: mov ax,0013h
int 10h
lea bp,error_msg ; Error message
mov cx,5 ; Message is 5 characters long
mov bx,0Ch ; Intesified red (BL), Page 0 (BH)
mov dx,0000h ; Line 00h, Column 00h
mov ax,1301h ; BIOS Textout function
push ds ; BIOS Textout function needs ES:BP
pop es
int 10h ; Call BIOS print function
clear: jmp clear ; Freeze
jcode: db 0EAh, 00h ; jmp 0800h:0000h
db 00h, 00h
db 08h
error_msg db 'ERROR'
ORG 510
db 55h, 0AAh
end
Code: Select all
[BITS 16]
[ORG 0x0000]
jmp @@start
@@start:
cli
lgdt [cs:gdt_desc] ; load the gdt
mov eax,cr0 ; move to protected mode
inc ax
mov cr0,eax
jmp 08:clear_pipe
[BITS 32]
clear_pipe:
mov ax,16
mov ds,ax
mov ss,ax
mov es,ax
mov fs,ax
mov gs,ax
mov esp,090000h
mov byte [ds:0B8000h],'P'
mov byte [ds:0B8000h],07h
hang:
jmp hang
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GDT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 4Gb limit ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gdt:
gdt_null:
dd 0
dd 0
gdt_code:
dw 0FFFFh ; limit_low
dw 0 ; base_low
db 0 ; base_middle
db 10011010b ;
db 11001111b ;
db 0 ; base_high
gdt_data:
dw 0FFFFh ; limit_low
dw 0 ; base_low
db 0 ; base_middle
db 10010010b ;
db 11001111b ;
db 0 ; base_high
gdt_end:
gdt_desc:
dw gdt_end - gdt - 1
dd gdt
- Robin