Last active
August 29, 2015 14:01
-
-
Save HaiyangXu/b06c58a4d26b97fbd3f2 to your computer and use it in GitHub Desktop.
A simple operating system or say, just a simple boot loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Code from http://mikeos.berlios.de/write-your-own-os.html | |
;See my cool solution to boot this 'OS‘,i think it's much cool. | |
; http://haiyangxu.github.io/posts/2014/2014-05-21-write_a_bootloader | |
BITS 16 | |
start: | |
mov ax, 07C0h ; Set up 4K stack space after this bootloader | |
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph | |
mov ss, ax | |
mov sp, 4096 | |
mov ax, 07C0h ; Set data segment to where we're loaded | |
mov ds, ax | |
mov si, text_string ; Put string position into SI | |
call print_string ; Call our string-printing routine | |
jmp $ ; Jump here - infinite loop! | |
text_string db 'This is my cool new OS!', 0 | |
print_string: ; Routine: output string in SI to screen | |
mov ah, 0Eh ; int 10h 'print char' function | |
.repeat: | |
lodsb ; Get character from string | |
cmp al, 0 | |
je .done ; If char is zero, end of string | |
int 10h ; Otherwise, print it | |
jmp .repeat | |
.done: | |
ret | |
times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s | |
dw 0xAA55 ; The standard PC boot signature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment