mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 22:08:05 +11:00
basic: add addr command
This commit is contained in:
parent
381d57a513
commit
8f1d942e5f
@ -25,6 +25,12 @@ Because the goal is not to provide a foundation for complex programs, I'm
|
||||
planning on intentionally crippling this BASIC dialect for the sake of
|
||||
simplicity.
|
||||
|
||||
The idea here is that the system administrator would build herself many little
|
||||
tools in assembler and BASIC would be the interactive glue to those tools.
|
||||
|
||||
If you find yourself writing complex programs in Collapse OS BASIC, you're on a
|
||||
wrong path. Back off, that program should be in assembler.
|
||||
|
||||
## Glueing
|
||||
|
||||
The `glue.asm` file in this folder represents the minimal basic system. There
|
||||
@ -144,6 +150,16 @@ output I/O on port 42 with value 3.
|
||||
**sleep**: Sleep a number of "units" specified by the supplied expression. A
|
||||
"unit" depends on the CPU clock speed. At 4MHz, it is roughly 8 microseconds.
|
||||
|
||||
**addr**: This very handy returns (in `A`), the address you query for. You can
|
||||
query for two types of things: commands or special stuff.
|
||||
|
||||
If you query for a command, type the name of the command as an argument. The
|
||||
address of the associated routine will be returned.
|
||||
|
||||
Then, there's the *special stuff*. This is the list of things you can query for:
|
||||
|
||||
* `$`: the scratchpad.
|
||||
|
||||
## Optional modules
|
||||
|
||||
As explained in "glueing" section abolve, this folder contains optional modules.
|
||||
|
@ -360,6 +360,45 @@ basSLEEP:
|
||||
dec hl ; 6T
|
||||
jr .loop ; 12T
|
||||
|
||||
basADDR:
|
||||
call rdWord
|
||||
ex de, hl
|
||||
ld de, .specialTbl
|
||||
.loop:
|
||||
ld a, (de)
|
||||
or a
|
||||
jr z, .notSpecial
|
||||
cp (hl)
|
||||
jr z, .found
|
||||
inc de \ inc de \ inc de
|
||||
jr .loop
|
||||
.notSpecial:
|
||||
; not found, find cmd. needle in (HL)
|
||||
ex de, hl ; now in (DE)
|
||||
ld hl, basCmds1
|
||||
call basFindCmd
|
||||
jr z, .foundCmd
|
||||
; no core command? let's try the find hook.
|
||||
ld ix, (BAS_FINDHOOK)
|
||||
call callIX
|
||||
ret nz
|
||||
.foundCmd:
|
||||
; We have routine addr in IX
|
||||
ld (VAR_TBL), ix
|
||||
cp a ; ensure Z
|
||||
ret
|
||||
.found:
|
||||
; found special thing. Put in "A".
|
||||
inc de
|
||||
call intoDE
|
||||
ld (VAR_TBL), de
|
||||
ret ; Z set from .found jump.
|
||||
|
||||
.specialTbl:
|
||||
.db '$'
|
||||
.dw SCRATCHPAD
|
||||
.db 0
|
||||
|
||||
; direct only
|
||||
basCmds1:
|
||||
.dw basBYE
|
||||
@ -394,4 +433,6 @@ basCmds2:
|
||||
.db "in", 0, 0, 0, 0
|
||||
.dw basSLEEP
|
||||
.db "sleep", 0
|
||||
.dw basADDR
|
||||
.db "addr", 0, 0
|
||||
.db 0xff, 0xff, 0xff ; end of table
|
||||
|
Loading…
Reference in New Issue
Block a user