;=============================================================== ; BOOT SECTOR ; [http://www.karig.net/001c.html] ;=============================================================== [ORG 0x7C00] [BITS 16] main: ; ------ Set up real-mode stack for BIOS calls. cli in al, 0x70 or al, 0x80 out 0x70, al mov ax, 0x1000 mov ss, ax xor sp, sp in al, 0x70 and al, 0x7F out 0x70, al sti ; ------ Delay for three seconds. ; ------ (Gives floppy controller time to finish BEFORE ; ------ we clear interrupts and enter protected mode.) xor cx, cx xor dx, dx mov ah, 1 int 0x1A ; set system timer to zero .zz: xor ah, ah int 0x1A cmp dx, 18*3 ; Timer ticks 18.2 times a second. jl .zz ; ------ Set VBE mode: 800x600, 64K colors mov bx, 0x4111 ; mode 0x111, linear, clear memory mov ax, 0x4F02 int 0x10 ; ------ Enable A20 line. (Method used in ColorForth) cli in al, 0x70 or al, 0x80 out 0x70, al mov al, 0xD1 out 0x64, al .20: in al, 0x64 and al, 2 jnz .20 mov al, 0x4B out 0x60, al ; ------ Load GDT and enter protected mode. lgdt [gdt] mov eax, cr0 or al, 1 mov cr0, eax jmp dword 8:pmstart [BITS 32] pmstart: mov eax, dseg-gdt mov ds, eax mov es, eax mov fs, eax mov gs, eax mov ss, eax ; ------ Draw color bands into screen buffer. cld mov edx, 6-1 ; six color bands to draw .d: mov ecx, 640*80/2 ; number of pixels to draw / 2 mov edi, [offsets+edx*4] mov eax, [colors+edx*4] rep stosd dec edx jns .d ; ------ Copy screen buffer into video memory. mov esi, [offsets] mov edi, 0xE0000000 mov ecx, 640*480/2 rep movsd ; ------ Hang computer. jmp $ ; ------ DATA. colors: dw 1111100000000000b, 1111100000000000b ; red dw 0000011111100000b, 0000011111100000b ; green dw 0000000000011111b, 0000000000011111b ; blue dw 1111100000011111b, 1111100000011111b ; magenta dw 1111111111100000b, 1111111111100000b ; yellow dw 0000011111111111b, 0000011111111111b ; cyan offsets: dd 0x200000 dd 0x200000+(640*80*2) dd 0x200000+(640*160*2) dd 0x200000+(640*240*2) dd 0x200000+(640*320*2) dd 0x200000+(640*400*2) align 8 gdt: dw 0x17 ; GDT limit (entry size * 3 - 1) dd gdt dw 0 cseg: dw 0xFFFF, 0, 0x9A00, 0x00CF ; code dseg: dw 0xFFFF, 0, 0x9200, 0x00CF ; data times 0x1FE - ($-$$) db 0 dw 0xAA55