From 12bc1203755c560553c05265ddb71b989f783a31 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 24 Nov 2019 20:34:23 -0500 Subject: [PATCH] basic: add bsel, bseek, getb, putb commands --- apps/basic/README.md | 25 ++++++++++++++++++++ apps/basic/blk.asm | 47 ++++++++++++++++++++++++++++++++++++++ tools/emul/bshell/glue.asm | 4 ++++ 3 files changed, 76 insertions(+) create mode 100644 apps/basic/blk.asm diff --git a/apps/basic/README.md b/apps/basic/README.md index 9fee770..ed77396 100644 --- a/apps/basic/README.md +++ b/apps/basic/README.md @@ -165,6 +165,31 @@ Then, there's the *special stuff*. This is the list of things you can query for: As explained in "glueing" section abolve, this folder contains optional modules. Here's the documentation for them. +### blk + +Block devices commands. Block devices are configured during kernel +initialization and are referred to by numbers. + +**bsel**: Select the active block device. The active block device is the target +of all commands below. You select it by specifying its number. For example, +`bsel 0` selects the first configured device. `bsel 1` selects the second. + +A freshly selected blkdev begins with its "pointer" at 0. + +**seek**: Moves the blkdev "pointer" to the specified offset. The first +argument is the offset's least significant half (blkdev supports 32-bit +addressing). Is is interpreted as an unsigned integer. + +The second argument is optional and is the most significant half of the address. +It defaults to 0. + +**getb**: Read a byte in active blkdev at current pointer, then advance the +pointer by one. Read byte goes in `A`. + +**putb**: Writes a byte in active blkdev at current pointer, then advance the +pointer by one. The value of the byte is determined by the expression supplied +as an argument. Example: `putb 42`. + ### fs `fs.asm` provides those commands: diff --git a/apps/basic/blk.asm b/apps/basic/blk.asm new file mode 100644 index 0000000..ac3a28b --- /dev/null +++ b/apps/basic/blk.asm @@ -0,0 +1,47 @@ +basBSEL: + call rdExpr + ret nz + push ix \ pop hl + call blkSelPtr + ld a, l + jp blkSel + +basBSEEK: + call rdExpr + ret nz + push ix ; --> lvl 1 + call rdExpr + push ix \ pop de + pop hl ; <-- lvl 1 + jr z, .skip + ; DE not supplied, set to zero + ld de, 0 +.skip: + xor a ; absolute mode + call blkSeek + cp a ; ensure Z + ret + +basGETB: + call blkGetB + ret nz + ld (VAR_TBL), a + ret + +basPUTB: + call rdExpr + ret nz + push ix \ pop hl + ld a, l + jp blkPutB + +basBLKCmds: + .dw basBSEL + .db "bsel", 0, 0 + .dw basBSEEK + .db "bseek", 0 + .dw basGETB + .db "getb", 0, 0 + .dw basPUTB + .db "putb", 0, 0 + .db 0xff, 0xff, 0xff ; end of table diff --git a/tools/emul/bshell/glue.asm b/tools/emul/bshell/glue.asm index b1e217a..ef26dd5 100644 --- a/tools/emul/bshell/glue.asm +++ b/tools/emul/bshell/glue.asm @@ -86,6 +86,7 @@ .inc "basic/buf.asm" .equ BFS_RAMSTART BUF_RAMEND .inc "basic/fs.asm" +.inc "basic/blk.asm" .equ BAS_RAMSTART BFS_RAMEND .inc "basic/main.asm" @@ -105,6 +106,9 @@ init: basFindCmdExtra: ld hl, basFSCmds + call basFindCmd + ret z + ld hl, basBLKCmds jp basFindCmd emulGetC: