From aad8efeff7262177172f03b1deadfc01c8667a9d Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 23 Nov 2019 21:22:31 -0500 Subject: [PATCH] recipes/rc2014/basic: new recipe --- recipes/rc2014/README.md | 1 + recipes/rc2014/basic/Makefile | 10 ++++++ recipes/rc2014/basic/README.md | 46 ++++++++++++++++++++++++++++ recipes/rc2014/basic/glue.asm | 56 ++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 recipes/rc2014/basic/Makefile create mode 100644 recipes/rc2014/basic/README.md create mode 100644 recipes/rc2014/basic/glue.asm diff --git a/recipes/rc2014/README.md b/recipes/rc2014/README.md index 6041d9b..72980e5 100644 --- a/recipes/rc2014/README.md +++ b/recipes/rc2014/README.md @@ -27,6 +27,7 @@ are other recipes related to the RC2014: * [Accessing a MicroSD card](sdcard/README.md) * [Assembling binaries](zasm/README.md) * [Interfacing a PS/2 keyboard](ps2/README.md) +* [Replace shell by a BASIC interpreter](basic/README.md) ## Recipe diff --git a/recipes/rc2014/basic/Makefile b/recipes/rc2014/basic/Makefile new file mode 100644 index 0000000..33fd356 --- /dev/null +++ b/recipes/rc2014/basic/Makefile @@ -0,0 +1,10 @@ +TARGET = os.bin +ZASM = ../../../tools/zasm.sh +KERNEL = ../../../kernel +APPS = ../../../apps + +.PHONY: all +all: $(TARGET) +$(TARGET): glue.asm + $(ZASM) $(KERNEL) $(APPS) < $< > $@ + diff --git a/recipes/rc2014/basic/README.md b/recipes/rc2014/basic/README.md new file mode 100644 index 0000000..5ae58b6 --- /dev/null +++ b/recipes/rc2014/basic/README.md @@ -0,0 +1,46 @@ +# BASIC as a shell + +This recipe demonstrate the replacement of the usual shell with the BASIC +interpreter supplied in Collapse OS. To make things fun, we play with I/Os +using RC2014's Digital I/O module. + +## Gathering parts + +* Same parts as in the base recipe +* (Optional) RC2014's Digital I/O module + +The Digital I/O module is only used in the example BASIC code. If you don't +have the module, just use BASIC in another fashion. + +## Build the image + +As usual, building `os.bin` is a matter of running `make`. Then, you can get +that image to your EEPROM like you did in the base recipe. + +## Usage + +Upon boot, you'll directy be in a BASIC prompt. See documentation in +`apps/basic/README.md` for details. + +For now, let's have some fun with the Digital I/O module. Type this: + +``` +> a=0 +> 10 out 0 a +> 20 sleep 0xffff +> 30 a=a+1 +> 40 goto 10 +> run +``` + +You now have your Digital I/O lights doing a pretty dance, forever. + +## Looking at the glue code + +If you look at the glue code, you'll see that it's very similar to the one in +the base recipe, except that the shell includes have been replaced by the basic +includes. Those includes have been copy/pasted from `apps/basic/glue.asm` and +`USER_RAMSTART` has been replaced with `STDIO_RAMEND` so that BASIC's memory +gets placed properly (that is, right after the kernel's memory). + +Simple, isn't it? diff --git a/recipes/rc2014/basic/glue.asm b/recipes/rc2014/basic/glue.asm new file mode 100644 index 0000000..0c10a01 --- /dev/null +++ b/recipes/rc2014/basic/glue.asm @@ -0,0 +1,56 @@ +.equ RAMSTART 0x8000 +.equ RAMEND 0xffff +.equ ACIA_CTL 0x80 ; Control and status. RS off. +.equ ACIA_IO 0x81 ; Transmit. RS on. +.equ DIGIT_IO 0x00 ; digital I/O's port + +jp init + +; interrupt hook +.fill 0x38-$ +jp aciaInt + +.inc "err.h" +.inc "ascii.h" +.inc "core.asm" +.inc "str.asm" +.equ ACIA_RAMSTART RAMSTART +.inc "acia.asm" + +.equ STDIO_RAMSTART ACIA_RAMEND +.equ STDIO_GETC aciaGetC +.equ STDIO_PUTC aciaPutC +.inc "stdio.asm" + +; *** BASIC *** + +; RAM space used in different routines for short term processing. +.equ SCRATCHPAD_SIZE 0x20 +.equ SCRATCHPAD STDIO_RAMEND +.inc "lib/util.asm" +.inc "lib/ari.asm" +.inc "lib/parse.asm" +.inc "lib/fmt.asm" +.equ EXPR_PARSE parseLiteralOrVar +.inc "lib/expr.asm" +.inc "basic/util.asm" +.inc "basic/parse.asm" +.inc "basic/tok.asm" +.equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE +.inc "basic/var.asm" +.equ BUF_RAMSTART VAR_RAMEND +.inc "basic/buf.asm" +.equ BAS_RAMSTART BUF_RAMEND +.inc "basic/main.asm" + +init: + di + ; setup stack + ld sp, RAMEND + im 1 + + call aciaInit + ei + jp basStart + +