mirror of https://github.com/E-Almqvist/eOS
parent
dac804d3bf
commit
a2eddaeba8
@ -1,32 +1,19 @@ |
|||||||
|
[org 0x7c00] ; bootsector |
||||||
|
|
||||||
|
jmp $ ; inf loop |
||||||
|
|
||||||
|
;; includes |
||||||
|
; EQU |
||||||
%include "equ/BIOS.asm" |
%include "equ/BIOS.asm" |
||||||
%include "equ/ASCII.asm" |
%include "equ/ASCII.asm" |
||||||
|
|
||||||
; eLIB |
; eLIB |
||||||
;; %include "elib/io.asm" |
;%include "elib/io.asm" |
||||||
|
|
||||||
mov ah, BIOS_MODE_TELETYPE ; enter teletype mode (BIOS) |
|
||||||
|
|
||||||
mov al, ASCII_LINEBREAK ; linebreak |
|
||||||
int BIOS_INT |
|
||||||
|
|
||||||
;; test db "Welcome to eOS", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK |
|
||||||
|
|
||||||
; Print "eOS" |
|
||||||
;; mov rcx, test |
|
||||||
;; call print |
|
||||||
|
|
||||||
; ALPHABET PRINT TEST |
|
||||||
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 |
|
||||||
|
|
||||||
cmp al, 90 ; 26 letters in english alphabet (64 + 26) |
|
||||||
jl loop ; if al < 64+26: jmp loop |
|
||||||
|
|
||||||
|
|
||||||
jmp $ |
;; Data |
||||||
|
welcomeString: |
||||||
|
db "Welcome to eOS", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK |
||||||
|
|
||||||
|
; Magic BIOS number |
||||||
times 510-($-$$) db 0 |
times 510-($-$$) db 0 |
||||||
db 0x55, 0xaa |
db 0x55, 0xaa |
||||||
|
@ -1,27 +1,34 @@ |
|||||||
; eLibrary |
; eLibrary |
||||||
; Input/Output subroutines |
; Input/Output subroutines |
||||||
|
|
||||||
; String structure |
; Subroutine to print a string |
||||||
; ASCII Offset = 8 bits |
print: |
||||||
; Array of the char bytes, ending with 0 (ASCII_END) |
pusha ; save current state of registers |
||||||
|
|
||||||
eLIB_STR_OFFSET equ 8 ; 8 bits |
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 |
||||||
|
|
||||||
print: ; Subroutine to print strings (from stack) |
|
||||||
; Input: RCX, takes pointer to string from stack |
|
||||||
pop rcx |
|
||||||
|
|
||||||
; rcx now holds the starting point (address) |
; BIOS Printing |
||||||
|
mov ah, BIOS_MODE_TELETYPE ; enter tty mode |
||||||
|
int BIOS_INT ; interupt and print the char (from line 10) |
||||||
|
|
||||||
printLoop: |
; Preperation for next iteration |
||||||
; Print the char |
inc bx ; increment the pointer to get next char |
||||||
mov al, [rcx] ; dereference address to get value |
jmp printLoop ; repeat |
||||||
cmp al, ASCII_END ; check if ASCII end |
|
||||||
je printExit ; if reached the end then return |
return: |
||||||
|
popa ; restore all registers |
||||||
|
ret ; return to previous location |
||||||
|
|
||||||
int BIOS_INT ; system interupt (print string) |
; Subroutine to print a string on a new line |
||||||
add rcx, eLIB_STR_OFFSET ; increase with offset |
newline: |
||||||
jmp printLoop ; loop for next char |
db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK |
||||||
|
|
||||||
printExit: |
println: |
||||||
ret |
; Print the newline |
||||||
|
mov bx, newline |
||||||
|
call print |
||||||
|
Loading…
Reference in new issue