1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-09-29 12:10:56 +10:00

basic: add bsel, bseek, getb, putb commands

This commit is contained in:
Virgil Dupras 2019-11-24 20:34:23 -05:00
parent 8f1d942e5f
commit 12bc120375
3 changed files with 76 additions and 0 deletions

View File

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

47
apps/basic/blk.asm Normal file
View File

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

View File

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