A poorly written OS for the x86 arch. (WIP)
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.
eOS/bootloader/bios/print.asm

52 lines
1.0 KiB

4 years ago
; Input/Output subroutines
; Subroutine to print a string
print:
pusha ; save current state of registers
4 years ago
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
4 years ago
; BIOS Printing
mov ah, BIOS_TTY_MODE ; enter teletype mode
int BIOS_TTY_INT ; interupt and print the char (from line 10)
4 years ago
; 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
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
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
; Print the newline
mov bx, newline
call print
4 years ago
popa
ret
; Subroutine to print a hex value
print_hex:
pusha
call hex_to_ascii
call print
popa
ret