Skip to content

Instantly share code, notes, and snippets.

@iKlsR
Created December 24, 2012 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iKlsR/4367430 to your computer and use it in GitHub Desktop.
Save iKlsR/4367430 to your computer and use it in GitHub Desktop.
early beginnings of a bootloader.. codenamed PINE
; -- nasm -f bin pine.s -o pine.bin
; -- copy pine.bin pine.img
; -- boot!
[BITS 16] ; make this into 16bit code
[ORG 0x7C00] ; load into memory here
_main:
mov ax, 0x0000 ; setup the data segment register (step1)
mov ds, ax ; move ax into ds (step2)
mov si, _testString ; a tmp test string to display
call _pChar ; run the put char proc
jmp $ ; jmp to the start of the instruction
_pChar:
mov ah, 0x0E ; put char on screen function
mov bh, 0x00 ; page number
mov bl, 0x07 ; txt attrib (bg and fg) [white - black]
._nxtChar: ; label (for loopinf around for the next char)
lodsb ; load the contents of SI int AL and [inc SI]
or al, al ; sets the Zero Flag if AL is null
jz ._return ; if ZF = null go to the end of the proc
int 0x10 ; call the bios video interrupt
jmp ._nxtChar ; loop around back to the top
._return:
ret ; leave and proceed (CALL)
_testHugeNum dd 0x00 ; 1 dw -> FFFFFFFF
_testLargNum dw 0x00 ; 1 word -> FFFF
_testSmalNum db 0x00 ; 1 byte -> FF
_testString db \
'A simple test from the pine bootloader.', 0x0D, 0x0A, '[halt]', 0
times 510-($-$$) db 0 ; fill the rest of the sector with 0s
dw 0xAA55 ; add the bootloader sig at the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment