123 lines
1.5 KiB
NASM
123 lines
1.5 KiB
NASM
CPU 8086
|
|
ORG 0x500
|
|
|
|
jmp start
|
|
|
|
;Calls
|
|
%include "CMPSTR.INC"
|
|
%include "PRINTSTR.INC"
|
|
%include "READSTR.INC"
|
|
%include "NEWLINE.INC"
|
|
%include "PRINTLN.INC"
|
|
%include "READLN.INC"
|
|
|
|
;Commands
|
|
%include "ECHO.INC"
|
|
%include "FILEIFY.INC"
|
|
%include "HELLO.INC"
|
|
%include "HELP.INC"
|
|
%include "KEYCODE.INC"
|
|
|
|
start:
|
|
|
|
;Set up the stack
|
|
cli
|
|
mov sp, stack
|
|
add sp, 0x100
|
|
sti
|
|
|
|
;Get the terminal width
|
|
mov ah, 0xf
|
|
int 0x10
|
|
mov [cpl], ah
|
|
|
|
;Print a welcome message
|
|
mov si, welcome
|
|
call println
|
|
|
|
loop:
|
|
|
|
;Prompt for and read a command
|
|
;Print a prompt
|
|
mov si, prompt
|
|
call printstr
|
|
;Read a command
|
|
mov di, buffer
|
|
mov al, 0xff
|
|
call readln
|
|
|
|
;Identify and execute the command
|
|
exec:
|
|
;Check for no command
|
|
cmp byte [buffer], 0x0
|
|
je loop
|
|
.echo:
|
|
;Check
|
|
mov si, buffer
|
|
mov di, cmd.echo
|
|
call cmpstr
|
|
jnc .fileify
|
|
;jnc .hello
|
|
;Execute
|
|
call echo
|
|
jmp loop
|
|
.fileify:
|
|
;Check
|
|
mov si, buffer
|
|
mov di, cmd.fileify
|
|
call cmpstr
|
|
jnc .hello
|
|
;Execute
|
|
call fileify
|
|
jmp loop
|
|
.hello:
|
|
;Check
|
|
mov si, buffer
|
|
mov di, cmd.hello
|
|
call cmpstr
|
|
jnc .help
|
|
;Execute
|
|
call hello
|
|
jmp loop
|
|
.help:
|
|
;Check
|
|
mov si, buffer
|
|
mov di, cmd.help
|
|
call cmpstr
|
|
jnc .keycode
|
|
;Execute
|
|
call help
|
|
jmp loop
|
|
.keycode:
|
|
;Check
|
|
mov si, buffer
|
|
mov di, cmd.keycode
|
|
call cmpstr
|
|
jnc .error
|
|
;Execute
|
|
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
|
|
.fileify db "fileify", 0x0
|
|
.hello db "hello", 0x0
|
|
.help db "help", 0x0
|
|
.keycode db "keycode", 0x0
|
|
|
|
error db "Unknown command", 0x0
|
|
|
|
buffer times 0xff db 0x0
|
|
|
|
stack:
|