An Example |
|
The following is a short BASIC program demonstrating the use of the last
two CIO calls. It is followed by an assembly language listing of the code contained in the DATA
statements and later in the string CIO$.
10 DIM CIO$(32),BUFFER$(64),DRIVE$(4),CHKDSK(17)
20 DRIVE$="Dl: ":DRIVE$(4)=CHR$(155)
30 RESTORE 50
40 FOR X=1 TO 32:READ Y:CIO$(X)=CHR$(Y):NEXT X
50 DATA 104,104,104,10,10,10,10,170,104,104,157,66,3
60 DATA 104,157,69,3,104,157,68,3,104,157,73,3,104,157
70 DATA 72,3,76,86,228
80 REM MAIN LOOP
90 BUFFER$(1)=CHR$(0):BUFFER$(64)=CHR$(0)
100 BUFFER$(2)=BUFFER$
110 ?:?"CIO Call Demonstrator"
120 ?:?"1 -> CHKDSK"
130 ?:?"2 -> Path to current directory"
140 INPUT CHOICE
150 IF CHOICE<>1 AND CHOICE<>2 THEN GOTO 120
160 ICCOM=CHOICE+46
170 ?:?"Which drive";:INPUT D
180 D=INT(D):IF D<l OR D>9 THEN GOTO 170
190 DRIVE$(2,2)=STR$(D):IOCB=l
200 X=USR(ADR(CIO$),IOCB,ICCOM,ADR(DRIVE$),ADR (BUFFER$) )
210 IF CHOICE=1 THEN GOTO 270
220 IF BUFFER$(1,1)=CHR$(0) THEN ?"Root directory":GOTO 80
230 FOR X=1 TO LEN(BUFFER$)
240 IF BUFFER$(X,X)=CHR$(0) THEN BUFFER$(X)=">":BUFFER$=BUFFER$(1,X):POP:GOTO 260
250 NEXT X
260 ? BUFFER$:GOTO 80
270 FOR X=1 TO 17:Y=ASC(BUFFER$(X,X)):CHKDSK(X-1)-Y:NEXT X
280 ?" Volume: "; BUFFER$(7,14)
290 ?"Bytes/sector: ";
300 IF CHKDSK(1)=0 THEN CHKDSK(1)=256
310 ? CHKDSK(1)
320 ?" Total bytes: "
330 ? CHKDSK(1)*(CHKDSK(2)+256*CHKDSK(3))
340 ?" Bytes free: ";
350 ? CHKDSK(1)*(CHKDSK(4)+256*CHKDSK(5))
360 GOTO 80
;origin is arbitrary since it will be in a string
ciov .equ $E456
iccom .equ $0342
icbal .equ $0344
icbah .equ $0345
icbll .equ $0348
icblh .equ $0349
*=$5000 ; or whatever
pla
; number of arguments.
pla
; should be 0
pla
; iocb channel number
asl a
; multiply by 16 for
asl a
; proper IOCB form
asl a
asl a
tax
; in x where it belongs
pla
; 0 again
pla
; command number
sta iccom,x
pla
; address of "Dx:" string
sta icbah,x
pla
sta icbal,x
pla
; buffer address
sta icblh,x
pla
sta icbll,x
jmp ciov
; all done. Jump CIO
|