mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 10:33:12 +00:00
Some file restructuring
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
;
|
||||
; Prints a string
|
||||
; si - Pointer to NULL terminated string
|
||||
;
|
||||
print:
|
||||
pusha
|
||||
mov ah, 0x0e
|
||||
mov bl, 0x0f
|
||||
mov bh, 0
|
||||
.loop:
|
||||
lodsb ; Load [si] into al; Increment si
|
||||
or al, al
|
||||
jz .done
|
||||
int 0x10
|
||||
jmp .loop
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
;
|
||||
; Prints a hex value
|
||||
; dx - Value to print in Hex
|
||||
;
|
||||
printHex:
|
||||
pusha
|
||||
xor cx, cx ; Init counter
|
||||
.loop:
|
||||
cmp cx, 4 ; Check for loop end
|
||||
je .done
|
||||
mov ax, dx ; Copy dx to ax
|
||||
and ax, 0x000f ; Get last nibble (4 bits) of ax
|
||||
add ax, '0' ; Convert number to an ASCII number (0-9)
|
||||
cmp ax, '9' ; Check if number was less than 9, meaning we can use it
|
||||
jle .addChar
|
||||
add ax, 0x07 ; Convert to letter (A-F)
|
||||
.addChar:
|
||||
mov bx, hexString + 5
|
||||
sub bx, cx ; Get position of current hex character
|
||||
mov [bx], al
|
||||
ror dx, 4 ; Rotate bits of dx (0x1a2b -> 0xb1a2)
|
||||
inc cx ; Increment the counter
|
||||
jmp .loop
|
||||
.done:
|
||||
mov si, hexString
|
||||
call print
|
||||
popa
|
||||
ret
|
||||
|
||||
;
|
||||
; Prints a hex byte
|
||||
; dl - Hex byte
|
||||
;
|
||||
printHexByte:
|
||||
pusha
|
||||
xor cx, cx
|
||||
.loop:
|
||||
mov al, dl
|
||||
and al, 0xF0
|
||||
ror al, 4
|
||||
add al, '0'
|
||||
cmp al, '9'
|
||||
jle .hexNum
|
||||
add al, 7
|
||||
.hexNum:
|
||||
mov ah, 0x0e
|
||||
int 0x10
|
||||
inc cx
|
||||
cmp cx, 2
|
||||
je .done
|
||||
ror dl, 4
|
||||
jmp .loop
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
hexString: db "0x0000", 0
|
||||
|
||||
;
|
||||
; Clears the screen
|
||||
;
|
||||
clear:
|
||||
pusha
|
||||
; TODO: Make this function
|
||||
popa
|
||||
ret
|
||||
|
||||
; Usefull definitions
|
||||
%define ENDL 0x0a, 0x0d
|
||||
newline: db ENDL, 0 ; CRLF
|
||||
@@ -0,0 +1,24 @@
|
||||
resetTextMode:
|
||||
pusha
|
||||
|
||||
mov ah, 0 ; Set mode
|
||||
mov al, 0x03 ; 25x80, Text mode
|
||||
int 0x10
|
||||
|
||||
mov ah, 0x0b ; Change color/palette
|
||||
mov bh, 0x00 ; Change BG color
|
||||
mov bl, 0x01 ; Blue BG
|
||||
int 0x10
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
resetGraphicsMode:
|
||||
pusha
|
||||
|
||||
mov ah, 0 ; Set mode
|
||||
mov al, 0x13 ; 320x200, 256 color graphics mode
|
||||
int 0x10
|
||||
|
||||
popa
|
||||
ret
|
||||
Reference in New Issue
Block a user