2021-06-10 15:16:14 +00:00
|
|
|
CPU 8086
|
2021-06-16 15:03:31 +00:00
|
|
|
ORG 0x500
|
2021-06-10 15:16:14 +00:00
|
|
|
|
2021-05-28 06:39:26 +00:00
|
|
|
jmp start
|
|
|
|
|
2021-05-30 16:12:19 +00:00
|
|
|
;Calls
|
2021-06-08 12:25:17 +00:00
|
|
|
%include "CMPSTR.INC"
|
2021-06-06 16:56:54 +00:00
|
|
|
%include "PRINTSTR.INC"
|
|
|
|
%include "READSTR.INC"
|
2021-06-16 19:00:45 +00:00
|
|
|
%include "NEWLINE.INC"
|
|
|
|
%include "PRINTLN.INC"
|
2021-06-06 16:56:54 +00:00
|
|
|
%include "READLN.INC"
|
2021-05-30 16:12:19 +00:00
|
|
|
|
|
|
|
;Commands
|
2021-06-06 16:56:54 +00:00
|
|
|
%include "ECHO.INC"
|
2021-06-16 19:00:45 +00:00
|
|
|
%include "FILEIFY.INC"
|
2021-06-06 16:56:54 +00:00
|
|
|
%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-06-16 15:03:31 +00:00
|
|
|
;Set up the stack
|
|
|
|
cli
|
|
|
|
mov sp, stack
|
|
|
|
add sp, 0x100
|
|
|
|
sti
|
|
|
|
|
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
|
|
|
|
2021-06-16 15:03:31 +00:00
|
|
|
;Prompt for and read a command
|
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-06-01 18:31:20 +00:00
|
|
|
;Identify and execute the command
|
2021-06-08 12:25:17 +00:00
|
|
|
exec:
|
2021-06-01 18:31:20 +00:00
|
|
|
;Check for no command
|
2021-05-30 16:12:19 +00:00
|
|
|
cmp byte [buffer], 0x0
|
|
|
|
je loop
|
|
|
|
.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-06-16 19:00:45 +00:00
|
|
|
jnc .fileify
|
|
|
|
;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-16 19:00:45 +00:00
|
|
|
.fileify:
|
|
|
|
;Check
|
|
|
|
mov si, buffer
|
|
|
|
mov di, cmd.fileify
|
|
|
|
call cmpstr
|
|
|
|
jnc .hello
|
|
|
|
;Execute
|
|
|
|
call fileify
|
|
|
|
jmp loop
|
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-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-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-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-06-10 15:16:14 +00:00
|
|
|
cpl db 0x0
|
2021-05-27 21:53:34 +00:00
|
|
|
|
2021-06-10 15:16:14 +00:00
|
|
|
welcome db 0xd, 0xa, "Welcome to EttinOS!", 0xd, 0xa, 0x0
|
2021-05-26 14:05:49 +00:00
|
|
|
|
2021-06-10 15:16:14 +00:00
|
|
|
prompt db "> ", 0x0
|
2021-05-26 14:05:49 +00:00
|
|
|
|
2021-05-28 06:39:26 +00:00
|
|
|
cmd:
|
2021-06-10 15:16:14 +00:00
|
|
|
.echo db "echo", 0x0
|
2021-06-16 15:03:31 +00:00
|
|
|
.fileify db "fileify", 0x0
|
2021-06-10 15:16:14 +00:00
|
|
|
.hello db "hello", 0x0
|
|
|
|
.help db "help", 0x0
|
|
|
|
.keycode db "keycode", 0x0
|
|
|
|
|
|
|
|
error db "Unknown command", 0x0
|
2021-05-30 16:12:19 +00:00
|
|
|
|
2021-06-16 15:03:31 +00:00
|
|
|
buffer times 0xff db 0x0
|
|
|
|
|
|
|
|
stack:
|