mirror of https://github.com/E-Almqvist/eOS
commit
c719b094c7
@ -1,50 +1,21 @@ |
|||||||
%include "equ/BIOS.asm" |
[org 0x7c00] ; bootsector |
||||||
%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 |
|
||||||
|
|
||||||
mov al, "S" |
|
||||||
int BIOS_INT |
|
||||||
|
|
||||||
mov al, ASCII_CARRIAGE_RETURN |
mov bx, welcomeString ; Print the welcome string |
||||||
int BIOS_INT |
call println |
||||||
|
|
||||||
mov al, ASCII_LINEBREAK ; linebreak |
jmp $ ; inf loop |
||||||
int BIOS_INT |
|
||||||
|
|
||||||
; ALPHABET PRINT |
;; includes |
||||||
mov al, 64 ; one less than A since we are printing in a loop and it increments before sys interupt |
; EQU |
||||||
loop: |
%include "equ/BIOS.asm" |
||||||
; Print the alphabetic char |
%include "equ/ASCII.asm" |
||||||
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 |
|
||||||
|
|
||||||
|
; eLIB |
||||||
|
%include "elib/io.asm" |
||||||
|
|
||||||
jmp $ |
;; Data |
||||||
|
welcomeString: db "Welcome to eOS", ASCII_END |
||||||
|
|
||||||
|
; Magic BIOS number |
||||||
times 510-($-$$) db 0 |
times 510-($-$$) db 0 |
||||||
db 0x55, 0xaa |
db 0x55, 0xaa |
||||||
|
@ -1,2 +1,42 @@ |
|||||||
; eLibrary |
; 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 |
||||||
|
Loading…
Reference in new issue