EttinOS/src/os.asm

111 lines
1.4 KiB
NASM

jmp start
;Calls
%include "printstr.inc"
%include "println.inc"
%include "readstr.inc" ;Under construction
%include "cmpstr.inc"
%include "byte2hexstr.inc"
;Commands
%include "echo.inc"
%include "hello.inc"
%include "help.inc"
%include "keycode.inc"
start:
;Initialise ds
mov ax, 0x1000
mov ds, ax
;Get the terminal width
mov ah, 0xf
int 0x10
mov [cpl], ah
;Print a welcome message
mov si, welcome
call println
loop:
;Print a prompt
mov si, prompt
call printstr
;Read a command
mov di, buffer
mov al, 0xff
call readstr
exec:
;No command
cmp byte [buffer], 0x0
je loop
.echo:
;Check for the command
mov si, buffer
mov di, cmd.echo
call cmpstr
jnc .hello
;Execute the command
call echo
jmp loop
.hello:
;Check for the command
mov si, buffer
mov di, cmd.hello
call cmpstr
jnc .help
;Execute the command
call hello
jmp loop
.help:
;Check for the command
mov si, buffer
mov di, cmd.help
call cmpstr
jnc .keycode
;Execute the command
call help
jmp loop
.keycode:
;Check for the command
mov si, buffer
mov di, cmd.keycode
call cmpstr
jnc .error
;Execute the command
call keycode
jmp loop
.error:
mov si, error
call println
jmp loop
cpl:
db 0x0
welcome:
db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
prompt:
db "> ", 0x0
cmd:
.echo:
db "echo", 0x0
.hello:
db "hello", 0x0
.help:
db "help", 0x0
.keycode:
db "keycode", 0x0
error:
db "Unknown command", 0x0
buffer:
times 0xff db 0