diff --git a/apps/basic/README.md b/apps/basic/README.md index 8cd7527..bc2d871 100644 --- a/apps/basic/README.md +++ b/apps/basic/README.md @@ -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. diff --git a/apps/basic/main.asm b/apps/basic/main.asm index ac1d251..2e1dca9 100644 --- a/apps/basic/main.asm +++ b/apps/basic/main.asm @@ -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