iocb equ $340 ciov equ $e456 org $2000 open 1 , 4 , 'D:IO.LAB' read 1, 7 , $bc40 , 80 close 1 rts /* OPEN Command: $03 - OPEN Example: open channel , command(4 or 8) , 'd:name' */ .macro open ldx #:1*16 lda #3 ; CIO command ; $03 - OPEN sta iocb+2,x lda name sta iocb+5,x lda #:2 ; $04 - READ ; $08 - WRITE sta iocb+$a,x __ciov jmp _skip name dta :3,$9b _skip .endm /* READ Command: $05 - GET RECORD $07 - GET CHARACTER $09 - PUT RECORD $0B - PUT CHARACTERS Example: read channel , command , buffer , length */ .macro read ldx #:1*16 lda #:2 ; CIO command sta iocb+2,x lda <:3 ; buffer address sta iocb+4,x lda >:3 sta iocb+5,x lda <:4 ; length sta iocb+8,x lda >:4 sta iocb+9,x __ciov .endm /* CLOSE Command: $0C - CLOSE Example: close channel */ .macro close ldx #:1*16 lda #$c ; CIO command sta iocb+2,x __ciov .endm /* __CIOV PROCEDURE */ .proc __ciov jsr ciov bmi error rts error tya :4 lsr @ tax lda hex,x sta io_code tya and #$0f tax lda hex,x sta io_code+1 ldx io_error jsr $c642 pla pla rts io_error dta 'I/O Error $' io_code dta ' ',$9b hex dta '0123456789ABCDEF' .endp