Added a os_upper_case function

This commit is contained in:
2025-10-30 22:57:31 +00:00
parent 0b9014d846
commit d83871e161
7 changed files with 193 additions and 83 deletions

View File

@@ -22,30 +22,41 @@ os_read_cli:
call os_print_newline
.check_matches: ; Check if the user input matches any internal commands
mov si, user_input
mov di, help_string
; Help
mov di, user_input
mov si, help_string
call os_compare_strings
cmp cl, 1
je help
mov si, user_input
mov di, clear_string
; Clear screen
mov di, user_input
mov si, clear_string
call os_compare_strings
cmp cl, 1
je clear
; Reboot
mov di, user_input
mov si, reboot_string
call os_compare_strings
cmp cl, 1
je os_reboot
; Reboot
mov di, user_input
mov si, cat_string
call os_compare_strings
cmp cl, 1
je cat
mov si, user_input
mov di, pong_string
; Pong
mov di, user_input
mov si, pong_string
call os_compare_strings
cmp cl, 1
je pong
mov si, user_input
mov di, snake_string
call os_compare_strings
cmp cl, 1
je snake
jmp .unkown
.unkown:
@@ -68,14 +79,14 @@ help:
call os_print_string_nl
call os_read_cli.finish
cat:
call util_cat
call os_read_cli.finish
pong:
call game_pong
call os_read_cli.finish
snake:
call game_snake
call os_read_cli.finish
section .data
welcome_text db 'Welcome to CrawOS, the Cool, Real and AWsome Operating System', 0
user_input times 20 db 0
@@ -83,8 +94,9 @@ section .data
prompt db 'CrawOS sh> ', 0
help_string db 'HELP', 0
clear_string db 'CLEAR', 0
reboot_string db 'REBOOT', 0
cat_string db 'CAT', 0
pong_string db 'PONG', 0
snake_string db 'SNAKE', 0
help_text db 'This is for Cowards: "HELP" for this help text, "CLEAR" to clear the screen, esc to reboot', 0
help_text db 'This is for Cowards: "HELP" for this help text, "CLEAR" to clear the screen, esc or "REBOOT" to reboot', 0
command_result_text db 'You typed: ', 0
unknown_command db 'Error: Unkown Command.. ', 0

View File

@@ -12,7 +12,7 @@ os_compare_strings:
.compare:
lodsb
scasb ; Compare di to si
jne .unequal ; If they are no equal, jump to .unequal
jne .unequal ; If they are not equal, jump to .unequal
cmp al, 0 ; Check if string is finished
je .equal ; If it has, return true
jmp .compare ; Finally, repeat
@@ -24,3 +24,26 @@ os_compare_strings:
.equal:
mov cl, 1
ret
; Convert a string to all upper case
os_upper_case:
pusha
mov di, si
.loop:
lodsb
inc di
cmp al, 0
je .finish
cmp al, 7Ah
jns .loop
cmp al, 61h
js .loop
sub al, 20h
dec di
stosb
jmp .loop
.finish:
popa
ret

View File

@@ -0,0 +1,18 @@
; Outputs the contents of a file
util_cat:
pusha
call os_print_newline
mov si, cat_prompt
call os_print_string
mov ax, 11 ; length of input
mov di, user_input
popa
ret
section .data:
cat_prompt db 'Enter file name: ', 0