         .include #system

open     sta   icbal,x
         tya
         sta   icbah,x
         lda   #3             ; OPEN
         bne   :doit


close    lda   #12            ; CLOSE
         bne   :doit


bput     sta   icbal,x
         tya
         sta   icbah,x
         lda   #11            ; PUT
         bne   :doit


bget     sta   icbal,x
         tya
         sta   icbah,x
         lda   #7             ; GET
:doit    sta   iccom,x
         jmp   CIOV


print    sta   icbal,x
         tya
         sta   icbah,x
         lda   #9             ; PRINT
         bne   :doit


input    sta   icbal,x
         tya
         sta   icbah,x
         lda   #5             ; INPUT
         bne   :doit

putc
         lda   #0
         sta   icbll,x
         sta   icblh,x
         lda   #11
         sta   iccom,x
         tya
         jmp   CIOV

getc
         lda   #<:buf
         sta   icbal,x
         lda   #>:buf
         sta   icbah,x
         lda   #1
         sta   icbll,x
         lda   #0
         sta   icblh,x
         lda   #7
         sta   iccom,x
         jsr   CIOV
         lda   :buf
         rts

:buf     .byte    0
_op_tab  .byte 0,$10,$20,$30,$40,$50,$60,$70
