mirror of https://github.com/E-Almqvist/eOS
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
51 lines
1.0 KiB
; 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 printreturn ; if al == ASCII_END then return end | lua is good psuedo-code
|
|
|
|
|
|
; BIOS Printing
|
|
mov ah, BIOS_TTY_MODE ; enter teletype mode
|
|
int BIOS_TTY_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
|
|
|
|
printreturn:
|
|
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
|
|
|
|
|
|
; Subroutine to print a hex value
|
|
print_hex:
|
|
pusha
|
|
call hex_to_ascii
|
|
call print
|
|
popa
|
|
|
|
ret
|
|
|