Updated print sr to work

pull/1/head
E. Almqvist 4 years ago
parent dac804d3bf
commit a2eddaeba8
  1. 35
      src/bootloader.asm
  2. 43
      src/elib/io.asm

@ -1,32 +1,19 @@
[org 0x7c00] ; bootsector
jmp $ ; inf loop
;; includes
; EQU
%include "equ/BIOS.asm"
%include "equ/ASCII.asm"
; eLIB
;; %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
;%include "elib/io.asm"
jmp $
;; Data
welcomeString:
db "Welcome to eOS", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK
; Magic BIOS number
times 510-($-$$) db 0
db 0x55, 0xaa

@ -1,27 +1,34 @@
; eLibrary
; Input/Output subroutines
; String structure
; ASCII Offset = 8 bits
; Array of the char bytes, ending with 0 (ASCII_END)
; Subroutine to print a string
print:
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:
; Print the char
mov al, [rcx] ; dereference address to get value
cmp al, ASCII_END ; check if ASCII end
je printExit ; if reached the end then return
; 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
int BIOS_INT ; system interupt (print string)
add rcx, eLIB_STR_OFFSET ; increase with offset
jmp printLoop ; loop for next char
; Subroutine to print a string on a new line
newline:
db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK
printExit:
ret
println:
; Print the newline
mov bx, newline
call print

Loading…
Cancel
Save