mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 04:18:06 +11:00
basic: add getc/putc commands
This commit is contained in:
parent
77485a0031
commit
4ba84dac5c
@ -149,6 +149,11 @@ input I/O on port 42 and stores the byte result in `A`.
|
|||||||
**out <port> <val>**: Same thing as `poke`, but for a I/O port. `out 42 1+2`
|
**out <port> <val>**: Same thing as `poke`, but for a I/O port. `out 42 1+2`
|
||||||
generates an output I/O on port 42 with value 3.
|
generates an output I/O on port 42 with value 3.
|
||||||
|
|
||||||
|
**getc**: Waits for a single character to be typed in the console and then puts
|
||||||
|
that value in `A`.
|
||||||
|
|
||||||
|
**putc <char>**: Puts the specified character to the console.
|
||||||
|
|
||||||
**sleep <units>**: Sleep a number of "units" specified by the supplied
|
**sleep <units>**: Sleep a number of "units" specified by the supplied
|
||||||
expression. A "unit" depends on the CPU clock speed. At 4MHz, it is roughly 8
|
expression. A "unit" depends on the CPU clock speed. At 4MHz, it is roughly 8
|
||||||
microseconds.
|
microseconds.
|
||||||
|
@ -26,6 +26,8 @@ basGETB:
|
|||||||
call blkGetB
|
call blkGetB
|
||||||
ret nz
|
ret nz
|
||||||
ld (VAR_TBL), a
|
ld (VAR_TBL), a
|
||||||
|
xor a
|
||||||
|
ld (VAR_TBL+1), a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
basPUTB:
|
basPUTB:
|
||||||
|
@ -126,16 +126,11 @@ basERR:
|
|||||||
;
|
;
|
||||||
; Commands are expected to set Z on success.
|
; Commands are expected to set Z on success.
|
||||||
basBYE:
|
basBYE:
|
||||||
ld hl, .sBye
|
|
||||||
call printstr
|
|
||||||
call printcrlf
|
|
||||||
; To quit the loop, let's return the stack to its initial value and
|
; To quit the loop, let's return the stack to its initial value and
|
||||||
; then return.
|
; then return.
|
||||||
xor a
|
xor a
|
||||||
ld sp, (BAS_INITSP)
|
ld sp, (BAS_INITSP)
|
||||||
ret
|
ret
|
||||||
.sBye:
|
|
||||||
.db "Goodbye!", 0
|
|
||||||
|
|
||||||
basLIST:
|
basLIST:
|
||||||
call bufFirst
|
call bufFirst
|
||||||
@ -349,6 +344,22 @@ basIN:
|
|||||||
; Z set from rdExpr
|
; Z set from rdExpr
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
basGETC:
|
||||||
|
call stdioGetC
|
||||||
|
ld (VAR_TBL), a
|
||||||
|
xor a
|
||||||
|
ld (VAR_TBL+1), a
|
||||||
|
ret
|
||||||
|
|
||||||
|
basPUTC:
|
||||||
|
call rdExpr
|
||||||
|
ret nz
|
||||||
|
push ix \ pop hl
|
||||||
|
ld a, l
|
||||||
|
call stdioPutC
|
||||||
|
xor a ; set Z
|
||||||
|
ret
|
||||||
|
|
||||||
basSLEEP:
|
basSLEEP:
|
||||||
call rdExpr
|
call rdExpr
|
||||||
ret nz
|
ret nz
|
||||||
@ -457,6 +468,10 @@ basCmds2:
|
|||||||
.db "out", 0, 0, 0
|
.db "out", 0, 0, 0
|
||||||
.dw basIN
|
.dw basIN
|
||||||
.db "in", 0, 0, 0, 0
|
.db "in", 0, 0, 0, 0
|
||||||
|
.dw basGETC
|
||||||
|
.db "getc", 0, 0
|
||||||
|
.dw basPUTC
|
||||||
|
.db "putc", 0, 0
|
||||||
.dw basSLEEP
|
.dw basSLEEP
|
||||||
.db "sleep", 0
|
.db "sleep", 0
|
||||||
.dw basADDR
|
.dw basADDR
|
||||||
|
Loading…
Reference in New Issue
Block a user