basic: add sleep command

also fix broken "peek"
This commit is contained in:
Virgil Dupras 2019-11-23 17:07:14 -05:00
parent 9602f9b983
commit 7761cebb0a
2 changed files with 17 additions and 0 deletions

View File

@ -114,3 +114,6 @@ of 0x002b into `a`'s MSB.
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.
**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.

View File

@ -272,6 +272,7 @@ basPEEK:
ret nz
ld d, 0
call varAssign
cp a ; ensure Z
ret
basPOKE:
@ -308,6 +309,17 @@ basDOKE:
ld (ix+1), h
ret
basSLEEP:
call rdExpr
ret nz
push ix \ pop hl
.loop:
ld a, h ; 4T
or l ; 4T
ret z ; 5T
dec hl ; 6T
jr .loop ; 12T
; direct only
basCmds1:
.dw basBYE
@ -334,4 +346,6 @@ basCmds2:
.db "deek", 0, 0
.dw basDOKE
.db "doke", 0, 0
.dw basSLEEP
.db "sleep", 0
.db 0xff, 0xff, 0xff ; end of table