[BITS 16] [ORG 7c00h] init: mov cx, 0xB800 mov gs, cx start: call clr_vga mov si, HELLO call write_str call disk_read call verify_read mov si, READ_NERR call write_str jmp 0x7e00 jmp hang read_err: mov si, READ_ERR call write_str hang: jmp hang verify_read: mov al, 0x66 cmp al, [0x7e00] jne read_err mov al, 0x55 cmp al, [0x7e01] jne read_err mov al, 0x66 cmp al, [0x7e02] jne read_err mov al, 0x89 cmp al, [0x7e03] jne read_err ret write_str: push ax push si xor ax, ax write_str_each_char: mov al, byte [si] cmp al, 0 je write_str_done inc si call write_char_default_attr jmp write_str_each_char write_str_done: pop si pop ax ret write_char_default_attr: push bx mov bl, 0x07 jmp write_char_inner write_char: push bx write_char_inner: push di mov di, [CURSOR_LOC] mov byte [gs:di], al inc di mov byte [gs:di], bl inc di mov [CURSOR_LOC], di pop di pop bx ret clr_vga: mov di, 4000 clr_vga_loop: dec di mov byte [gs:di], 0x00 cmp di, 0 jne clr_vga_loop mov word [CURSOR_LOC], 0 ret disk_read: ; ax = disk number to read from ; reference: http://www.delorie.com/djgpp/doc/rbinter/id/14/7.html mov dx, 0x80 or ax, dx mov si, LBA_DISK_READ_PACKET mov ah, 0x42 int 0x13 jc read_err ret READ_ERR: db 'Read failed: ', 0 READ_NERR: db 'No err reading, continuing: ', 0 HELLO: db 'Bootloader init: ', 0 CURSOR_LOC: dw 0 ; reference: http://www.delorie.com/djgpp/doc/rbinter/it/72/2.html LBA_DISK_READ_PACKET: db 0x10 db 0 dw 32 ; number of blocks to read, reset to # actually read when done dw 0x7e00 ; read destination address dw 0x0000 dd 1 ; lba to read from dd 0 ; for extended lba adresses (not really used here) ; times 510-($-$$) db 0 ; db 0x55 ; db 0xAA