diff --git a/src/bootloader.asm b/src/bootloader.asm index 02fb35b..f07345c 100644 --- a/src/bootloader.asm +++ b/src/bootloader.asm @@ -1,50 +1,21 @@ -%include "equ/BIOS.asm" -%include "equ/ASCII.asm" - -mov ah, BIOS_MODE_TELETYPE ; enter teletype mode (BIOS) - -mov al, ASCII_LINEBREAK ; linebreak -int BIOS_INT - -; Print "eOS" -mov al, "e" -int BIOS_INT - -mov al, "O" -int BIOS_INT +[org 0x7c00] ; bootsector -mov al, "S" -int BIOS_INT +mov bx, welcomeString ; Print the welcome string +call println -mov al, ASCII_CARRIAGE_RETURN -int BIOS_INT +jmp $ ; inf loop -mov al, ASCII_LINEBREAK ; linebreak -int BIOS_INT - -; ALPHABET PRINT -mov al, 64 ; one less than A since we are printing in a loop and it increments before sys interupt -loop: - ; Print the alphabetic char - inc al ; move to next char - int BIOS_INT ; bios interupt to print it - - push ax ; push ax onto stack - - ; newline - mov al, ASCII_CARRIAGE_RETURN - int BIOS_INT - mov al, ASCII_LINEBREAK - int BIOS_INT - - ; Prepair for next iteration - pop ax ; restore - - cmp al, 90 ; 26 letters in english alphabet (64 + 26) - jl loop ; if al < 64+26: jmp loop +;; includes +; EQU +%include "equ/BIOS.asm" +%include "equ/ASCII.asm" +; eLIB +%include "elib/io.asm" -jmp $ +;; Data +welcomeString: db "Welcome to eOS", ASCII_END +; Magic BIOS number times 510-($-$$) db 0 db 0x55, 0xaa diff --git a/src/elib/io.asm b/src/elib/io.asm index 49b94f2..10ed003 100644 --- a/src/elib/io.asm +++ b/src/elib/io.asm @@ -1,2 +1,42 @@ ; eLibrary -; Input/Output sr +; Input/Output subroutines + +; Subroutine to print a string +print: + pusha ; save current state of registers + + printLoop: + ; Char check + mov al, [bx] ; load the char + cmp al, ASCII_END ; check if end of string + je return ; if al == ASCII_END then return end | lua is good psuedo-code + + + ; BIOS Printing + mov ah, BIOS_MODE_TELETYPE ; enter tty mode + int BIOS_INT ; interupt and print the char (from line 10) + + ; Preperation for next iteration + inc bx ; increment the pointer to get next char + jmp printLoop ; repeat + + return: + popa ; restore all registers + ret ; return to previous location + + +newline: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, ASCII_END ; used for printing newlines + +; Subroutine to print a string on a new line +println: + pusha + + ; Print the input string + call print ; this will print whatever is in [bx], so clear it if you dont want to print anything + + ; Print the newline + mov bx, newline + call print + + popa + ret