Appendix B
The Inkey Program
Assembly Language Listing of Inkey
An assembled version of Inkey is included on the CONFIG/
BASIC09 diskette. Use Inkey from BASIC09 with the RUN
statement.
~ INKEY - a subroutine for BASIC09 by Robert Doggett
~ Called by; RUN INKEY(StrVar)
RUN INKEY(Path,StrVar)
~ INKEY determines if a key has been typed on the given path
~ (Standard Input if not specified), and if so, returns the next
~ character in the String Variable. If no key has been typed, the
~ null string is returned, If a path
i5
Specified, it must be
~ either type BYTE or INTEGER.
NAM INKEY
IFP1
USE /D0/DEFS/OS9DEFS
ENDC
0021 TYPE
0081 REVS
0000 87CDOOSE
OOOD 496E6H65
D 0000
D 0000
D 0002
D 0004
D 0006
D 0008
D 000A
000C
000E
0012 3064
Set SHRTN+OBJCT
Set REENT+1
InKeyNam
fc5
org
Return rmb
PCount rmb
Param1 rmb
Length1 rmb
Param2 rmb
Length2 rmb
E3Param e9u
SIZE equ
InKeyEnt leax
mod InKeyEnd,InKeyNam,TYPE,REVS
,InKeyEnt,SIZE
"Inkey"
0
2
2
2
2
2
2
$38
Paraml,S
Parameters
Return addr of caller
Num of params following
1st param addr
Size
2nd param addr
size
BASIC09 Commands Reference
0014 EC62 ldd Pcount,S Get parameter count
0016 10830001
cmpd x1 just one parameter?
001A 2727 beq InKey20 _Yes; default path A=0
001C 10830002 cmpd x2 Are there two param5?
0020 2635 bne ParamErr No, abort
0022 ECF804 ldd fParam1,S] Get path number
0025 AE66 ldx Lengthl,S
0027 301E leax -1,X byte variable?
0029 2706 beq InKey10
_Yes; (A)=Path number
002E 301E leax -1,X Integer?
002D 2628 bne ParamErr _ No; abort
002E 1F98 tfr H,A
0031 3068 InKey10 leax Param2,S
0033 EE02 InKey20 ldu 2,X length of string
0035 AE84 ldx O,X addr of string
0037 C6FF ldb xsFF
0039 E784 stb
O,X Initialize to null str
0038 11830002 cmpu #2 at least two-byte str?
003E 2502 blo InKey30 _ No
0041 E701 5tb 1,X put str terminator
0043 C601 InKey30 ldb #SS,Ready
0045 103FBD OS9 I$GetStt i5 there any data ready?
0048 2508 bcs
InKey90 _ No; exit
004A 108E0001 ldy x1
004E 103F89
OS9 I$Read Read one byte
0051 39 rt5 returns error status
0052 C1F6 InKey90 cmpb xE$NotRdy
0054 2603 bne InKeyErr
0056 39
its (carry clear)
0057 C638 ParamErr ldb xESParam Parameter Error
0059 43 InKeyErr coma
005A 39 its
0058 1A6916
emod
005E InKeyEnd equ
B-2