mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:48: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`
|
||||
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
|
||||
expression. A "unit" depends on the CPU clock speed. At 4MHz, it is roughly 8
|
||||
microseconds.
|
||||
|
@ -26,6 +26,8 @@ basGETB:
|
||||
call blkGetB
|
||||
ret nz
|
||||
ld (VAR_TBL), a
|
||||
xor a
|
||||
ld (VAR_TBL+1), a
|
||||
ret
|
||||
|
||||
basPUTB:
|
||||
|
@ -126,16 +126,11 @@ basERR:
|
||||
;
|
||||
; Commands are expected to set Z on success.
|
||||
basBYE:
|
||||
ld hl, .sBye
|
||||
call printstr
|
||||
call printcrlf
|
||||
; To quit the loop, let's return the stack to its initial value and
|
||||
; then return.
|
||||
xor a
|
||||
ld sp, (BAS_INITSP)
|
||||
ret
|
||||
.sBye:
|
||||
.db "Goodbye!", 0
|
||||
|
||||
basLIST:
|
||||
call bufFirst
|
||||
@ -349,6 +344,22 @@ basIN:
|
||||
; Z set from rdExpr
|
||||
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:
|
||||
call rdExpr
|
||||
ret nz
|
||||
@ -457,6 +468,10 @@ basCmds2:
|
||||
.db "out", 0, 0, 0
|
||||
.dw basIN
|
||||
.db "in", 0, 0, 0, 0
|
||||
.dw basGETC
|
||||
.db "getc", 0, 0
|
||||
.dw basPUTC
|
||||
.db "putc", 0, 0
|
||||
.dw basSLEEP
|
||||
.db "sleep", 0
|
||||
.dw basADDR
|
||||
|
Loading…
Reference in New Issue
Block a user