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.
52 lines
1.0 KiB
52 lines
1.0 KiB
4 years ago
|
; Input/Output subroutines
|
||
|
|
||
4 years ago
|
; Subroutine to print a string
|
||
|
print:
|
||
|
pusha ; save current state of registers
|
||
4 years ago
|
|
||
4 years ago
|
printLoop:
|
||
|
; Char check
|
||
|
mov al, [bx] ; load the char
|
||
|
cmp al, ASCII_END ; check if end of string
|
||
4 years ago
|
je printreturn ; if al == ASCII_END then return end | lua is good psuedo-code
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
; BIOS Printing
|
||
4 years ago
|
mov ah, BIOS_TTY_MODE ; enter teletype mode
|
||
|
int BIOS_TTY_INT ; interupt and print the char (from line 10)
|
||
4 years ago
|
|
||
4 years ago
|
; Preperation for next iteration
|
||
|
inc bx ; increment the pointer to get next char
|
||
|
jmp printLoop ; repeat
|
||
|
|
||
4 years ago
|
printreturn:
|
||
4 years ago
|
popa ; restore all registers
|
||
|
ret ; return to previous location
|
||
4 years ago
|
|
||
|
|
||
4 years ago
|
newline: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, ASCII_END ; used for printing newlines
|
||
|
|
||
|
; Subroutine to print a string on a new line
|
||
4 years ago
|
println:
|
||
4 years ago
|
pusha
|
||
|
|
||
|
; Print the input string
|
||
|
call print ; this will print whatever is in [bx], so clear it if you dont want to print anything
|
||
|
|
||
4 years ago
|
; Print the newline
|
||
|
mov bx, newline
|
||
|
call print
|
||
4 years ago
|
|
||
|
popa
|
||
|
ret
|
||
4 years ago
|
|
||
|
|
||
|
; Subroutine to print a hex value
|
||
|
print_hex:
|
||
|
pusha
|
||
|
call hex_to_ascii
|
||
|
call print
|
||
|
popa
|
||
|
|
||
|
ret
|