mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 01:48:06 +11:00
Compare commits
2 Commits
8f1d942e5f
...
a0daed6812
Author | SHA1 | Date | |
---|---|---|---|
|
a0daed6812 | ||
|
12bc120375 |
@ -160,11 +160,49 @@ Then, there's the *special stuff*. This is the list of things you can query for:
|
||||
|
||||
* `$`: the scratchpad.
|
||||
|
||||
**usr**: This calls the memory address specified as an expression argument.
|
||||
Before doing so, it sets the registers according to a specific logic: Variable
|
||||
`A`'s LSB goes in register `A`, variable `D` goes in register `DE`, `H` in `HL`
|
||||
`B` in `BC` and `X` in `IX`. `IY` can't be used because it's used for the jump.
|
||||
Then, after the call, the value of the registers are put back into the
|
||||
variables following the same logic.
|
||||
|
||||
Let's say, for example, that you want to use the kernel's `printstr` to print
|
||||
the contents of the scratchpad. First, you would call `addr $` to put the
|
||||
address of the scratchpad in `A`, then do `h=a` to have that address in `HL`
|
||||
and, if printstr is, for example, the 21st entry in your jump table, you'd do
|
||||
`usr 21*3` and see the scratchpad printed!
|
||||
|
||||
## Optional modules
|
||||
|
||||
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
47
apps/basic/blk.asm
Normal 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
|
@ -399,6 +399,31 @@ basADDR:
|
||||
.dw SCRATCHPAD
|
||||
.db 0
|
||||
|
||||
basUSR:
|
||||
call rdExpr
|
||||
ret nz
|
||||
push ix \ pop iy
|
||||
; We have our address to call. Now, let's set up our registers.
|
||||
; HL comes from variable H. H's index is 7*2.
|
||||
ld hl, (VAR_TBL+14)
|
||||
; DE comes from variable D. D's index is 3*2
|
||||
ld de, (VAR_TBL+6)
|
||||
; BC comes from variable B. B's index is 1*2
|
||||
ld bc, (VAR_TBL+2)
|
||||
; IX comes from variable X. X's index is 23*2
|
||||
ld ix, (VAR_TBL+46)
|
||||
; and finally, A
|
||||
ld a, (VAR_TBL)
|
||||
call callIY
|
||||
; Same dance, opposite way
|
||||
ld (VAR_TBL), a
|
||||
ld (VAR_TBL+46), ix
|
||||
ld (VAR_TBL+2), bc
|
||||
ld (VAR_TBL+6), de
|
||||
ld (VAR_TBL+14), hl
|
||||
cp a ; USR never errors out
|
||||
ret
|
||||
|
||||
; direct only
|
||||
basCmds1:
|
||||
.dw basBYE
|
||||
@ -435,4 +460,6 @@ basCmds2:
|
||||
.db "sleep", 0
|
||||
.dw basADDR
|
||||
.db "addr", 0, 0
|
||||
.dw basUSR
|
||||
.db "usr", 0, 0, 0
|
||||
.db 0xff, 0xff, 0xff ; end of table
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user