From 20151a97f845c0e9fae157407f7af46e6095013d Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 11 Dec 2019 13:01:51 -0500 Subject: [PATCH] recipes/rc2014/zasm: use BASIC shell Also made Makefile actually portable. --- apps/at28w/glue.asm | 5 +- apps/lib/args.asm | 3 ++ apps/lib/fmt.asm | 1 + apps/lib/parse.asm | 2 + apps/memt/glue.asm | 4 +- apps/sdct/glue.asm | 4 +- recipes/rc2014/zasm/Makefile | 17 ++---- recipes/rc2014/zasm/cfsin/hello.asm | 1 - recipes/rc2014/zasm/glue.asm | 84 ++++++++++++++++------------- recipes/rc2014/zasm/user.h | 11 ++-- tools/emul/Makefile | 4 +- 11 files changed, 74 insertions(+), 62 deletions(-) diff --git a/apps/at28w/glue.asm b/apps/at28w/glue.asm index c9f3f93..c8b5d82 100644 --- a/apps/at28w/glue.asm +++ b/apps/at28w/glue.asm @@ -10,7 +10,6 @@ ; *** Requirements *** ; blkGetB -; parseArgs ; ; *** Includes *** @@ -20,5 +19,9 @@ jp at28wMain +.inc "core.asm" +.inc "lib/util.asm" +.inc "lib/parse.asm" +.inc "lib/args.asm" .inc "at28w/main.asm" USER_RAMSTART: diff --git a/apps/lib/args.asm b/apps/lib/args.asm index 86bcbe7..ced7757 100644 --- a/apps/lib/args.asm +++ b/apps/lib/args.asm @@ -1,3 +1,6 @@ +; *** Requirements *** +; lib/parse +; ; *** Consts *** ; maximum number of bytes to receive as args in all commands. Determines the ; size of the args variable. diff --git a/apps/lib/fmt.asm b/apps/lib/fmt.asm index c0a720e..6909712 100644 --- a/apps/lib/fmt.asm +++ b/apps/lib/fmt.asm @@ -1,5 +1,6 @@ ; *** Requirements *** ; stdioPutC +; divide ; ; Same as fmtDecimal, but DE is considered a signed number diff --git a/apps/lib/parse.asm b/apps/lib/parse.asm index 86ee32b..22f8207 100644 --- a/apps/lib/parse.asm +++ b/apps/lib/parse.asm @@ -1,3 +1,5 @@ +; *** Requirements *** +; lib/util ; *** Code *** ; Parse the hex char at A and extract it's 0-15 numerical value. Put the result diff --git a/apps/memt/glue.asm b/apps/memt/glue.asm index 2a3ef0d..f3389f3 100644 --- a/apps/memt/glue.asm +++ b/apps/memt/glue.asm @@ -8,12 +8,14 @@ ; ; *** Requirements *** ; printstr -; printHexPair +; stdioPutC ; ; *** Includes *** .inc "user.h" jp memtMain +.inc "lib/ari.asm" +.inc "lib/fmt.asm" .inc "memt/main.asm" USER_RAMSTART: diff --git a/apps/sdct/glue.asm b/apps/sdct/glue.asm index 0a28419..72227d9 100644 --- a/apps/sdct/glue.asm +++ b/apps/sdct/glue.asm @@ -14,7 +14,7 @@ ; sdcPutB ; sdcGetB ; printstr -; printHexPair +; stdioPutC ; ; *** Includes *** @@ -23,5 +23,7 @@ jp sdctMain +.inc "lib/ari.asm" +.inc "lib/fmt.asm" .inc "sdct/main.asm" USER_RAMSTART: diff --git a/recipes/rc2014/zasm/Makefile b/recipes/rc2014/zasm/Makefile index cd29d6d..3bd165a 100644 --- a/recipes/rc2014/zasm/Makefile +++ b/recipes/rc2014/zasm/Makefile @@ -1,4 +1,6 @@ -CFSTARGETS = $(addprefix cfsin/, zasm sdct memt at28w user.h) +SHELLAPPS = zasm sdct memt at28w +APPTARGETS = ${SHELLAPPS:%=cfsin/%} +CFSTARGETS = $(APPTARGETS) cfsin/user.h BASE = ../../.. TOOLS = $(BASE)/tools ZASM = $(TOOLS)/zasm.sh @@ -18,17 +20,8 @@ $(CFSPACK): sdcard.cfs: $(CFSTARGETS) $(CFSPACK) $(CFSPACK) cfsin > $@ -cfsin/zasm: $(ZASMBIN) - $(ZASM) $(KERNEL) $(APPS) user.h < $(APPS)/zasm/glue.asm > $@ - -cfsin/sdct: $(ZASMBIN) - $(ZASM) $(APPS) user.h < $(APPS)/sdct/glue.asm > $@ - -cfsin/memt: $(ZASMBIN) - $(ZASM) $(APPS) user.h < $(APPS)/memt/glue.asm > $@ - -cfsin/at28w: $(ZASMBIN) - $(ZASM) $(APPS) $(KERNEL) user.h < $(APPS)/at28w/glue.asm > $@ +$(APPTARGETS): $(ZASMBIN) + $(ZASM) $(KERNEL) $(APPS) user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@ cfsin/user.h: user.h cp $< $@ diff --git a/recipes/rc2014/zasm/cfsin/hello.asm b/recipes/rc2014/zasm/cfsin/hello.asm index e342bc7..bcb32bd 100644 --- a/recipes/rc2014/zasm/cfsin/hello.asm +++ b/recipes/rc2014/zasm/cfsin/hello.asm @@ -1,5 +1,4 @@ .inc "user.h" -.org USER_CODE ld hl, sAwesome call printstr diff --git a/recipes/rc2014/zasm/glue.asm b/recipes/rc2014/zasm/glue.asm index cdc33a0..c5b022f 100644 --- a/recipes/rc2014/zasm/glue.asm +++ b/recipes/rc2014/zasm/glue.asm @@ -1,11 +1,11 @@ ; classic RC2014 setup (8K ROM + 32K RAM) and a stock Serial I/O module ; The RAM module is selected on A15, so it has the range 0x8000-0xffff .equ RAMSTART 0x8000 -; kernel RAM usage, because of SDC, is a bit high and bring us almost to 0x8500 -; We allocate at least 0x200 bytes for the stack, which is why we have this +; Kernel RAMEND last check: 0x98f3 +; We allocate at least 0x100 bytes for the stack, which is why we have this ; threshold. -.equ RAMEND 0x8700 -.equ PGM_CODEADDR RAMEND +.equ RAMEND 0x9a00 +.equ USER_CODE RAMEND ; in sync with user.h .equ ACIA_CTL 0x80 ; Control and status. RS off. .equ ACIA_IO 0x81 ; Transmit. RS on. @@ -15,30 +15,25 @@ jp strncmp jp upcase jp findchar - jp parseHex - jp parseHexPair jp blkSel jp blkSet jp fsFindFN jp fsOpen jp fsGetB - jp parseArgs jp printstr jp _blkGetB jp _blkPutB jp _blkSeek jp _blkTell - jp printHexPair ; approaching 0x38... + jp sdcGetB + jp sdcPutB + jp blkGetB + jp stdioPutC ; interrupt hook .fill 0x38-$ jp aciaInt -; *** Jump Table (cont.) *** - jp sdcGetB - jp sdcPutB - jp blkGetB - .inc "err.h" .inc "ascii.h" .inc "blkdev.h" @@ -69,25 +64,32 @@ jp aciaInt .equ FS_HANDLE_COUNT 2 .inc "fs.asm" -; *** Shell *** +; *** BASIC *** + +; RAM space used in different routines for short term processing. +.equ SCRATCHPAD_SIZE 0x20 +.equ SCRATCHPAD FS_RAMEND .inc "lib/util.asm" +.inc "lib/ari.asm" .inc "lib/parse.asm" -.inc "lib/args.asm" -.inc "lib/stdio.asm" -.equ SHELL_RAMSTART FS_RAMEND -.equ SHELL_EXTRA_CMD_COUNT 11 -.inc "shell/main.asm" -.dw sdcInitializeCmd, sdcFlushCmd -.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd -.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd +.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" +.inc "basic/blk.asm" +.inc "basic/sdc.asm" +.equ BFS_RAMSTART BUF_RAMEND +.inc "basic/fs.asm" +.equ BAS_RAMSTART BFS_RAMEND +.inc "basic/main.asm" -.inc "shell/fs.asm" -.inc "shell/blkdev.asm" - -.equ PGM_RAMSTART SHELL_RAMEND -.inc "shell/pgm.asm" - -.equ SDC_RAMSTART PGM_RAMEND +.equ SDC_RAMSTART BAS_RAMEND .equ SDC_PORT_CSHIGH 6 .equ SDC_PORT_CSLOW 5 .equ SDC_PORT_SPI 4 @@ -97,22 +99,32 @@ jp aciaInt init: di - ; setup stack - ld hl, RAMEND - ld sp, hl + ld sp, RAMEND im 1 call aciaInit call fsInit - call shellInit - ld hl, pgmShellHook - ld (SHELL_CMDHOOK), hl + call basInit + ld hl, basFindCmdExtra + ld (BAS_FINDHOOK), hl xor a ld de, BLOCKDEV_SEL call blkSel ei - jp shellLoop + jp basStart + +basFindCmdExtra: + ld hl, basFSCmds + call basFindCmd + ret z + ld hl, basBLKCmds + call basFindCmd + ret z + ld hl, basSDCCmds + call basFindCmd + ret z + jp basPgmHook ; *** blkdev 1: file handle 0 *** diff --git a/recipes/rc2014/zasm/user.h b/recipes/rc2014/zasm/user.h index 0ef18f9..6f81ca8 100644 --- a/recipes/rc2014/zasm/user.h +++ b/recipes/rc2014/zasm/user.h @@ -1,25 +1,20 @@ -.org 0x8700 +.org 0x9a00 ; *** JUMP TABLE *** .equ strncmp 0x03 .equ upcase @+3 .equ findchar @+3 -.equ parseHex @+3 -.equ parseHexPair @+3 .equ blkSel @+3 .equ blkSet @+3 .equ fsFindFN @+3 .equ fsOpen @+3 .equ fsGetB @+3 -.equ parseArgs @+3 .equ printstr @+3 .equ _blkGetB @+3 .equ _blkPutB @+3 .equ _blkSeek @+3 .equ _blkTell @+3 -.equ printHexPair @+3 -; now at 0x36 - -.equ sdcGetB 0x3b +.equ sdcGetB @+3 .equ sdcPutB @+3 .equ blkGetB @+3 +.equ stdioPutC @+3 diff --git a/tools/emul/Makefile b/tools/emul/Makefile index 6ab9e99..05a5425 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -5,7 +5,7 @@ APPS = ../../apps ZASMBIN = zasm/zasm ZASMSH = ../zasm.sh SHELLAPPS = zasm ed -SHELLTGTS = ${SHELLAPPS:S/^/cfsin\//} +SHELLTGTS = ${SHELLAPPS:%=cfsin/%} CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h OBJS = emul.o libz80/libz80.o @@ -55,7 +55,7 @@ $(CFSPACK): # -o in sync with USER_CODE in shell/user.h $(SHELLTGTS): $(ZASMBIN) - $(ZASMSH) -o 42 $(KERNEL) $(APPS) shell/user.h < $(APPS)/${@:T}/glue.asm > $@ + $(ZASMSH) -o 42 $(KERNEL) $(APPS) shell/user.h < $(APPS)/${@:cfsin/%=%}/glue.asm > $@ cfsin/user.h: shell/user.h cp shell/user.h $@