chapter8/CH8PRG5.SRC:

10     *   =    $600
20 HATABS  =    $031A
40 START   LDY  #0
60 LOOP    LDA  HATABS,Y
70         CMP  #0  ;  FREE ENTRY?
80         BEQ  FOUND
90         INY
0100       INY
0110       INY ;  POINT TO NEXT HATABS ENTRY
0120       CPY  #34  ;  AT END OF HATABS?
0130       BNE  LOOP  ;  NO ... CONTINUE
0140       SEC  ;  YES... INDICATE ERROR
0150       RTS
0160 ;
0180 FOUND LDA  #'N ;  SET DEVICE NAME
0190       STA  HATABS,Y
0200       INY
0210       LDA  #NULLTAB&255
0220       STA  HATABS,Y  ;  HANDLER ADDRESS
0230       INY
0240       LDA  #NULLTAB/256
0250       STA  HATABS,Y
0260       RTS
0270 ;
0290 NULLTAB .WORD  RTHAND-1   ;  OPEN
0300         .WORD  RTHAND-1   ;  CLOSE
0310         .WORD  NOFUNC-1   ;  READ
0320         .WORD  RTHAND-1   ;  WRITE
0330         .WORD  RTHAND-1   ;  STATUS
0340         .WORD  NOFUNC-1   ;  SPECIAL
0350         JMP    RTHAND     ;  INITILIZATION
0360 ;
0380 RTHAND  LDY  #1  ;  SUCCESSFUL I/O FUNCTION
0400 NOFUNC  RTS  ;  FUNCTION NOT IMPLEMENTED

Back to previous page