2021-05-28 06:39:26 +00:00
|
|
|
jmp start
|
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;Calls
|
|
|
|
%include "printstr.inc"
|
|
|
|
%include "println.inc"
|
2021-06-01 18:31:20 +00:00
|
|
|
%include "readln.inc"
|
|
|
|
%include "newline.inc"
|
2021-05-30 16:12:19 +00:00
|
|
|
%include "cmpstr.inc"
|
|
|
|
%include "byte2hexstr.inc"
|
|
|
|
|
|
|
|
;Commands
|
|
|
|
%include "echo.inc"
|
|
|
|
%include "hello.inc"
|
|
|
|
%include "help.inc"
|
|
|
|
%include "keycode.inc"
|
2021-05-28 06:39:26 +00:00
|
|
|
|
|
|
|
start:
|
2021-05-26 17:43:46 +00:00
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;Initialise ds
|
2021-05-26 14:05:49 +00:00
|
|
|
mov ax, 0x1000
|
|
|
|
mov ds, ax
|
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;Get the terminal width
|
2021-05-27 21:53:34 +00:00
|
|
|
mov ah, 0xf
|
|
|
|
int 0x10
|
2021-05-30 16:12:19 +00:00
|
|
|
mov [cpl], ah
|
2021-05-27 21:53:34 +00:00
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;Print a welcome message
|
2021-05-26 14:05:49 +00:00
|
|
|
mov si, welcome
|
2021-05-30 16:12:19 +00:00
|
|
|
call println
|
2021-05-26 14:05:49 +00:00
|
|
|
|
|
|
|
loop:
|
2021-05-30 16:12:19 +00:00
|
|
|
|
|
|
|
;Print a prompt
|
2021-05-26 14:05:49 +00:00
|
|
|
mov si, prompt
|
2021-05-28 06:39:26 +00:00
|
|
|
call printstr
|
2021-05-30 16:12:19 +00:00
|
|
|
|
|
|
|
;Read a command
|
|
|
|
mov di, buffer
|
|
|
|
mov al, 0xff
|
2021-06-01 18:31:20 +00:00
|
|
|
call readln
|
2021-05-30 16:12:19 +00:00
|
|
|
|
2021-05-28 06:39:26 +00:00
|
|
|
exec:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Identify and execute the command
|
|
|
|
|
|
|
|
;Check for no command
|
2021-05-30 16:12:19 +00:00
|
|
|
cmp byte [buffer], 0x0
|
|
|
|
je loop
|
2021-06-01 18:31:20 +00:00
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
.echo:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Check
|
2021-05-30 16:12:19 +00:00
|
|
|
mov si, buffer
|
|
|
|
mov di, cmd.echo
|
2021-05-28 06:39:26 +00:00
|
|
|
call cmpstr
|
2021-05-27 18:00:50 +00:00
|
|
|
jnc .hello
|
2021-06-01 18:31:20 +00:00
|
|
|
;Execute
|
2021-05-30 16:12:19 +00:00
|
|
|
call echo
|
2021-05-27 18:00:50 +00:00
|
|
|
jmp loop
|
2021-06-01 18:31:20 +00:00
|
|
|
|
2021-05-26 17:43:46 +00:00
|
|
|
.hello:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Check
|
2021-05-30 16:12:19 +00:00
|
|
|
mov si, buffer
|
2021-05-28 06:39:26 +00:00
|
|
|
mov di, cmd.hello
|
|
|
|
call cmpstr
|
2021-05-30 16:12:19 +00:00
|
|
|
jnc .help
|
2021-06-01 18:31:20 +00:00
|
|
|
;Execute
|
2021-05-26 17:43:46 +00:00
|
|
|
call hello
|
|
|
|
jmp loop
|
2021-06-01 18:31:20 +00:00
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
.help:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Check
|
2021-05-30 16:12:19 +00:00
|
|
|
mov si, buffer
|
|
|
|
mov di, cmd.help
|
2021-05-28 06:39:26 +00:00
|
|
|
call cmpstr
|
2021-05-27 18:00:50 +00:00
|
|
|
jnc .keycode
|
2021-06-01 18:31:20 +00:00
|
|
|
;Execute
|
2021-05-30 16:12:19 +00:00
|
|
|
call help
|
2021-05-26 17:15:44 +00:00
|
|
|
jmp loop
|
2021-06-01 18:31:20 +00:00
|
|
|
|
2021-05-27 18:00:50 +00:00
|
|
|
.keycode:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Check
|
2021-05-30 16:12:19 +00:00
|
|
|
mov si, buffer
|
2021-05-28 06:39:26 +00:00
|
|
|
mov di, cmd.keycode
|
|
|
|
call cmpstr
|
|
|
|
jnc .error
|
2021-06-01 18:31:20 +00:00
|
|
|
;Execute
|
2021-05-27 18:00:50 +00:00
|
|
|
call keycode
|
|
|
|
jmp loop
|
2021-06-01 18:31:20 +00:00
|
|
|
|
2021-05-28 06:39:26 +00:00
|
|
|
.error:
|
2021-05-30 16:12:19 +00:00
|
|
|
mov si, error
|
|
|
|
call println
|
2021-05-26 17:15:44 +00:00
|
|
|
jmp loop
|
|
|
|
|
2021-05-27 21:53:34 +00:00
|
|
|
cpl:
|
2021-05-30 16:12:19 +00:00
|
|
|
db 0x0
|
2021-05-27 21:53:34 +00:00
|
|
|
|
2021-05-26 14:05:49 +00:00
|
|
|
welcome:
|
2021-05-30 16:12:19 +00:00
|
|
|
db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
2021-05-26 14:05:49 +00:00
|
|
|
|
|
|
|
prompt:
|
2021-05-30 16:12:19 +00:00
|
|
|
db "> ", 0x0
|
2021-05-26 14:05:49 +00:00
|
|
|
|
2021-05-28 06:39:26 +00:00
|
|
|
cmd:
|
2021-05-26 17:43:46 +00:00
|
|
|
.echo:
|
2021-05-30 16:12:19 +00:00
|
|
|
db "echo", 0x0
|
|
|
|
.hello:
|
|
|
|
db "hello", 0x0
|
|
|
|
.help:
|
|
|
|
db "help", 0x0
|
2021-05-27 18:00:50 +00:00
|
|
|
.keycode:
|
2021-05-30 16:12:19 +00:00
|
|
|
db "keycode", 0x0
|
|
|
|
|
|
|
|
error:
|
|
|
|
db "Unknown command", 0x0
|
|
|
|
|
|
|
|
buffer:
|
2021-05-31 15:48:13 +00:00
|
|
|
times 0xff db 0
|