mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 05:08:05 +11:00
basic: add peek/poke/deek/doke commands
This commit is contained in:
parent
585e9f3b6e
commit
9602f9b983
@ -103,3 +103,14 @@ stored where specified. For example, `input x` stores the result of the
|
||||
evaluation in variable `x`. Before the variable name, a quoted string literal
|
||||
can be specified. In that case, that string will be printed as-is just before
|
||||
the prompt.
|
||||
|
||||
**peek/deek**: Put the value at specified memory address into specified
|
||||
variable. peek is for a single byte, deek is for a word (little endian). For
|
||||
example, `peek 42 a` puts the byte value contained in memory address 0x002a
|
||||
into variable `a`. `deek 42 a` does the same as peek, but also puts the value
|
||||
of 0x002b into `a`'s MSB.
|
||||
|
||||
**poke/doke**: Put the value of specified expression into specified memory
|
||||
address. For example, `poke 42 0x102+0x40` puts `0x42` in memory address
|
||||
0x2a (MSB is ignored) and `doke 42 0x102+0x40` does the same as poke, but also
|
||||
puts `0x01` in memory address 0x2b.
|
||||
|
@ -267,6 +267,47 @@ basINPUT:
|
||||
cp a ; ensure Z
|
||||
ret
|
||||
|
||||
basPEEK:
|
||||
call basDEEK
|
||||
ret nz
|
||||
ld d, 0
|
||||
call varAssign
|
||||
ret
|
||||
|
||||
basPOKE:
|
||||
call rdExpr
|
||||
ret nz
|
||||
; peek address in IX. Save it for later
|
||||
push ix ; --> lvl 1
|
||||
call rdSep
|
||||
call rdExpr
|
||||
push ix \ pop hl
|
||||
pop ix ; <-- lvl 1
|
||||
ret nz
|
||||
; Poke!
|
||||
ld (ix), l
|
||||
ret
|
||||
|
||||
basDEEK:
|
||||
call rdExpr
|
||||
ret nz
|
||||
; peek address in IX. Let's peek and put result in DE
|
||||
ld e, (ix)
|
||||
ld d, (ix+1)
|
||||
call rdSep
|
||||
ld a, (hl)
|
||||
call varChk
|
||||
ret nz ; not in variable range
|
||||
; All good assign
|
||||
call varAssign
|
||||
cp a ; ensure Z
|
||||
ret
|
||||
|
||||
basDOKE:
|
||||
call basPOKE
|
||||
ld (ix+1), h
|
||||
ret
|
||||
|
||||
; direct only
|
||||
basCmds1:
|
||||
.dw basBYE
|
||||
@ -285,4 +326,12 @@ basCmds2:
|
||||
.db "if", 0, 0, 0, 0
|
||||
.dw basINPUT
|
||||
.db "input", 0
|
||||
.dw basPEEK
|
||||
.db "peek", 0, 0
|
||||
.dw basPOKE
|
||||
.db "poke", 0, 0
|
||||
.dw basDEEK
|
||||
.db "deek", 0, 0
|
||||
.dw basDOKE
|
||||
.db "doke", 0, 0
|
||||
.db 0xff, 0xff, 0xff ; end of table
|
||||
|
@ -85,3 +85,15 @@ rdWord:
|
||||
pop de
|
||||
pop af
|
||||
ret
|
||||
|
||||
; Read word from HL in SCRATCHPAD and then intepret that word as an expression.
|
||||
; Put the result in IX.
|
||||
; Z for success.
|
||||
rdExpr:
|
||||
ld de, SCRATCHPAD
|
||||
call rdWord
|
||||
push hl
|
||||
ex de, hl
|
||||
call parseExpr
|
||||
pop hl
|
||||
ret
|
||||
|
Loading…
Reference in New Issue
Block a user