Streamline the commands and give the major parts of the code headings

This commit is contained in:
CrazyEttin 2021-05-26 20:43:46 +03:00
parent 0c0c882b21
commit 0daa68f804
1 changed files with 46 additions and 32 deletions

View File

@ -1,3 +1,5 @@
;Main
mov ax, 0x1000
mov ds, ax
@ -10,32 +12,28 @@ call print
call read
cmp byte [input], 0
je loop
mov si, input
mov di, cmdhello
call compare
jc .hello
mov si, input
mov di, cmdecho
call compare
jc .echo
mov si, unknown
call print
jmp loop
execute:
.hello:
mov si, hello
mov si, input
mov di, command.hello
call compare
jnc .echo
call hello
jmp loop
.echo:
mov si, input
mov di, command.echo
call compare
jnc .unknown
call echo
jmp loop
.unknown:
mov si, command.unknown
call print
jmp loop
.echo:
call read
cmp byte [input], 0
je loop
mov si, input
call print
mov si, newline
call print
jmp loop
;Calls
print:
lodsb
@ -132,12 +130,39 @@ ret
stc
ret
hello:
mov si, .msg
call print
ret
.msg:
db "Hello world!", 0xd, 0xa, 0
echo:
call read
cmp byte [input], 0
je loop
mov si, input
call print
mov si, newline
call print
ret
;Data
welcome:
db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0xd, 0xa, 0
prompt:
db "> ", 0
command:
.hello:
db "hello", 0
.echo:
db "echo", 0
.unknown:
db "Unknown command", 0xd, 0xa, 0
newline:
db 0xd, 0xa, 0
@ -145,14 +170,3 @@ input:
times 0x80 db 0
.end:
db 0
unknown:
db "Unknown command", 0xd, 0xa, 0
cmdhello:
db "hello", 0
hello:
db "Hello world!", 0xd, 0xa, 0
cmdecho:
db "echo", 0