CPU 8086 ORG 0x500 jmp start ;Interrupt handler int0x20: jmp shell int0x21: cmp ah, 0x0 je printstr cmp ah, 0x1 je readstr cmp ah, 0x2 je println cmp ah, 0x3 je readln iret int0x22: ;To do: loading and saving files iret ;System calls %include "PRINTSTR.INC" %include "READSTR.INC" %include "PRINTLN.INC" %include "READLN.INC" ;Internal calls %include "CMPSTR.INC" %include "NEWLINE.INC" ;Commands %include "ECHO.INC" %include "FILEIFY.INC" %include "HELLO.INC" %include "HELP.INC" %include "KEYCODE.INC" start: ;Setup ;Set up the stack cli mov sp, stack add sp, 0x100 sti ;Set up the interrupt vectors ;Interrupt 0x20 mov ax, int0x20 mov [0x80], ax mov ax, 0x0 mov [0x82], ax ;Interrupt 0x21 mov ax, int0x21 mov [0x84], ax mov ax, 0x0 mov [0x86], ax ;Interrupt 0x22 mov ax, int0x22 mov [0x88], ax mov ax, 0x0 mov [0x8a], ax ;Print a welcome message mov si, welcomemsg mov ah, 0x2 int 0x21 shell: ;Prompt for and read a command ;Print a prompt mov si, prompt mov ah, 0x0 int 0x21 ;Read a command mov di, buffer mov al, 0xff mov ah, 0x3 int 0x21 ;Identify and execute the command exec: ;Check for no command cmp byte [buffer], 0x0 je shell .echo: ;Check mov si, buffer mov di, cmd.echo call cmpstr jnc .fileify ;Execute call echo jmp shell .fileify: ;Check mov si, buffer mov di, cmd.fileify call cmpstr jnc .hello ;Execute call fileify jmp shell .hello: ;Check mov si, buffer mov di, cmd.hello call cmpstr jnc .help ;Execute call hello jmp shell .help: ;Check mov si, buffer mov di, cmd.help call cmpstr jnc .keycode ;Execute call help jmp shell .keycode: ;Check mov si, buffer mov di, cmd.keycode call cmpstr jnc .error ;Execute call keycode jmp shell .error: mov si, errormsg mov ah, 0x2 int 0x21 jmp shell welcomemsg 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 errormsg db "Unknown command", 0x0 buffer times 0xff db 0x0 stack: