All pastes #985089 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-04-14 19:46 UTC
rendered paste body
; bootloader.s

[BITS 16]               ; Emit 16bit code
[ORG 0x7C00]            ; The BIOS loads the boatloader at offset 0x7C00

xor bl, bl              ; Segment selector, not used here (zero)

call clear_screen 
call print_string

cli                     ; Disable interrupts
hlt                     ; Halt the processor

print_string:
mov al, 1
mov bh, 0
mov bl, 07h
mov cx, hello_end - hello 
mov dl, 0
mov dh, 0
mov bp, hello
mov ah, 13h 
int 10h

ret

clear_screen:
xor al, al
mov bh, 07h

xor ch, ch
xor cl, cl

mov dh, 25
mov dl, 80

mov ah, 07h
int 10h

xor dh, dh
xor dl, dl

xor bh, bh
mov ah, 2
int 10h

ret

hello db "Hello World!"
hello_end:

times 510-($-$$) db 0   ; Fill the remaining 510 bytes with 0
dw 0xAA55               ; End with AA55 otherwise the BIOS won't recognise this as a bootsector