From 92d93714bd6e7f8255fb4ea624af19ac324aeda0 Mon Sep 17 00:00:00 2001 From: CrazyEttin <> Date: Fri, 25 Jun 2021 20:24:38 +0300 Subject: [PATCH] Write echo, update the readme with information on how the commands work, and replace a lodsb stosb loop in the shell with a movsb one. --- README.MD | 26 ++++++++++++++++++++++---- make.sh | 4 +++- src/ECHO.ASM | 12 ++++++++++++ src/LOADF.INC | 8 ++++---- src/SYSTEM.ASM | 5 +---- 5 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 src/ECHO.ASM diff --git a/README.MD b/README.MD index 6f3eb58..ad21d94 100644 --- a/README.MD +++ b/README.MD @@ -19,10 +19,10 @@ Building Build dependencies: * A Unix-like operating system * coreutils - * rw (optional) * dosfstools * mtools * nasm + * rw (optional) Running make.sh will build EttinOS and create a bootable 360 KiB 5.25" floppy disk image named EttinOS.img. To get a 1.44 MB 3.5" one instead @@ -37,14 +37,32 @@ The EttinOS input system is inspired by typewriters. Typing a character overwrites the cursor location and the erase (=tab) key erases it. The space and backspace keys move the cursor. +Commands +-------- + +EttinOS commands consist of the case-insensitive command itself followed +by a tail separated with a space. Extra spaces, be they leading, +trailing, or between a command and its tail, are ignored. What the tail +contains and how it should be formatted depends on the command. Tails on +commands that do not use them are ignored. All commands except for +changing the drive are stored as external programs, and you must be on +the same drive as the program file to execute one. A command for a +program does not include its filename extension. + +Commands included in EttinOS by default: + * [A-D]:: Changes the drive. + * ECHO: Echoes its tail. + * HELLO: A hello world program. + Programming ----------- EttinOS has a flat address space of 64 KiB. The data, stack, and extra segments are set at the beginning of the RAM and the system stack -at the end of the address space. Programs are loaded at address 0x2000. -The stack is reset back to the end of the address space after a program -has finished running. +at the end of the address space. Programs are loaded at address 0x2000 +and SI is pointed at the command tail, a string ending in a null, when +the program is executed. The stack is reset back to the end of the +address space after a program has finished running. System calls: * Interrupt 0x20: Return to the shell. diff --git a/make.sh b/make.sh index a6b996d..c78dacc 100755 --- a/make.sh +++ b/make.sh @@ -9,6 +9,7 @@ if [ "$1" = "-1440" ] else nasm BOOT.ASM -f bin -o ../bin/BOOT.BIN fi nasm SYSTEM.ASM -f bin -o ../bin/SYSTEM.BIN +nasm ECHO.ASM -f bin -o ../bin/ECHO.BIN nasm HELLO.ASM -f bin -o ../bin/HELLO.BIN cd .. @@ -22,6 +23,7 @@ if which rw > /dev/null 2>&1 else dd if=bin/BOOT.BIN of=EttinOS.img conv=notrunc bs=512 count=1 1>/dev/null fi mcopy -i EttinOS.img bin/SYSTEM.BIN :: -mcopy -i EttinOS.img bin/HELLO.BIN :: mcopy -i EttinOS.img README.MD :: mcopy -i EttinOS.img LICENSE.MD :: +mcopy -i EttinOS.img bin/ECHO.BIN :: +mcopy -i EttinOS.img bin/HELLO.BIN :: diff --git a/src/ECHO.ASM b/src/ECHO.ASM new file mode 100644 index 0000000..50688e9 --- /dev/null +++ b/src/ECHO.ASM @@ -0,0 +1,12 @@ +CPU 8086 +ORG 0x2000 + +;Echoes its command tail +;Check for an empty tail +cmp byte [si], 0x0 +je done +;Echo +mov ah, 0x2 +int 0x21 +done: +int 0x20 diff --git a/src/LOADF.INC b/src/LOADF.INC index 3136fd8..e1dbf08 100644 --- a/src/LOADF.INC +++ b/src/LOADF.INC @@ -22,10 +22,10 @@ sub di, 0xb ;Convert .file into FAT formatting -;Initialise the length counter for the main part of the name +;Initialise the length counter for the main part of the filename mov bl, 0x8 -;Convert the main part of the file name +;Convert the main part of the filename .nameloop: ;Load a character lodsb @@ -53,7 +53,7 @@ pop ax call .checkconv jmp .extloop -;Set the carry flag if the file name is invalid +;Set the carry flag if the filename is invalid .error: pop ax stc @@ -260,7 +260,7 @@ iret .cluster dw 0x0 .pointer dw 0x0 -;Check the file name and convert to upper case +;Check the filename and convert to upper case .checkconv: ;Check for the string end cmp al, 0x0 diff --git a/src/SYSTEM.ASM b/src/SYSTEM.ASM index 7a05636..26bd8ad 100644 --- a/src/SYSTEM.ASM +++ b/src/SYSTEM.ASM @@ -126,10 +126,7 @@ addext: push si mov si, extension mov cx, 0x5 -.loop: -lodsb -stosb -loop .loop +rep movsb ;Load and execute the program ;Load