1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-18 05:28:05 +11:00

recipes/rc2014/basic: new recipe

This commit is contained in:
Virgil Dupras 2019-11-23 21:22:31 -05:00
parent b7d4860acf
commit aad8efeff7
4 changed files with 113 additions and 0 deletions

View File

@ -27,6 +27,7 @@ are other recipes related to the RC2014:
* [Accessing a MicroSD card](sdcard/README.md) * [Accessing a MicroSD card](sdcard/README.md)
* [Assembling binaries](zasm/README.md) * [Assembling binaries](zasm/README.md)
* [Interfacing a PS/2 keyboard](ps2/README.md) * [Interfacing a PS/2 keyboard](ps2/README.md)
* [Replace shell by a BASIC interpreter](basic/README.md)
## Recipe ## Recipe

View File

@ -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) < $< > $@

View File

@ -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?

View File

@ -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