home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / libinc / header / cio.h65 < prev    next >
Text File  |  1993-01-19  |  4KB  |  193 lines

  1.    .if .not .def _CIO_
  2. _CIO_ = 1
  3.  
  4.       .if .not .def _SYSTEM_
  5.          .include #system
  6.       .endif
  7.       .if .not .def _MACROS_
  8.          .include #macros
  9.       .endif
  10.  
  11. @READ     = 4
  12. @WRITE    = 8
  13. @APPEND   = 9
  14. @UPDATE   = @WRITE + @READ
  15.  
  16. @S_TXTWIN    = 16
  17. @S_NOCLEAR   = 32
  18.  
  19. ; -------------------------------------------------------------
  20. ; For the macro...
  21. ;              CH_X  channel[,select]
  22. ; will get us
  23. ;     channel in X
  24. ; -------------------------------------------------------------
  25.    .macro ch_x
  26.       .if %0 = 1 .or .not [%2 & @special]  ;; this works as in `C`
  27.          .if %0 = 2 .and .not [%2 & @p1]
  28.             ldx   #%1
  29.             lda   _op_tab,x
  30.             tax
  31.          .else
  32.             .if %1 >= 8
  33.                ldx   #%1
  34.             .else
  35.                ldx   #%1*$10
  36.             .endif
  37.          .endif
  38.       .endif
  39.    .endm
  40.  
  41. ; -------------------------------------------------------------
  42. ; For the macro...
  43. ;              OPEN  channel,aux1,aux2,filespec[,select]
  44. ; will get us
  45. ;     channel in X
  46. ; -------------------------------------------------------------
  47.    .macro open
  48. @3    .= @p1 ! @p2 ! @p3 ! @p4 ! @s4
  49.       .if %0 = 5
  50. @3       .= %5
  51.       .endif
  52.       ch_x  %1,@3
  53.       @moke_x  %2,icax1,[@3 & @p2] / @p2
  54.       @moke_x  %3,icax2,[@3 & @p3] / @p3
  55.       .if @3 & @s4
  56.          jmp   *+%4+4
  57.          .byte %$4,0
  58.          @dmoad *-%4-1,@p1
  59.       .else
  60.          @dmoad %4,[@3 & @p4] / @p4
  61.       .endif
  62.       jsr   open
  63.    .endm
  64.  
  65. ; ------------------------------------------------------------
  66. ; For the macro...
  67. ;            CLOSE  channel[,select]
  68. ; will get us
  69. ;   channel in X
  70. ; ------------------------------------------------------------
  71.    .macro close
  72. @3    .= @p1 ! @special
  73.       .if %0 = 2
  74. @3       .= %2
  75.       .endif
  76.       ch_x  %1,@3
  77.       jsr   close
  78.    .endm
  79.  
  80. ; -------------------------------------------------------------
  81. ; Generic macro for calls of the form
  82. ;        channel,buffer,len[,select]
  83. ; Like INPUT PRINT BPUT BGET
  84. ; Usage: IO channel,buffer,len,select,jumplabel
  85. ; Default assumption: channel in X everything POKEd
  86. ; -------------------------------------------------------------
  87.    .macro   _io
  88.        ch_x  %1,%4
  89.        @dmoke_x %3,icbll,[%4 & @p3] / @p3
  90.        @dmoad   %2,[%4 & @p2] / @p2
  91.       jsr   %5
  92.    .endm
  93.  
  94. ; -------------------------------------------------------------
  95. ; For the macros...
  96. ;              BPUT  channel,buffer,len[,select]]
  97. ;              BGET  channel,buffer,len[,select]
  98. ;              PRINT channel,buffer[,len[,select]]
  99. ;              INPUT channel,buffer,len[,select]
  100. ; The ommission of len on PRINT is only recommended
  101. ; for quick'n dirty hacks, since your wasting 3 bytes.
  102. ; Assumption:
  103. ;     channel in X everything POKEd
  104. ; -------------------------------------------------------------
  105.    .macro bput
  106. @3    .= @p1 ! @p2 ! @p3
  107.       .if %0 = 4
  108. @3       .= %4
  109.       .endif
  110.       _io %1,%2,%3,@3,bput
  111.    .endm
  112.  
  113.    .macro bget
  114. @3    .= @p1 ! @p2 ! @p3
  115.       .if %0 = 4
  116. @3       .= %4
  117.       .endif
  118.       _io %1,%2,%3,@3,bget
  119.    .endm
  120.  
  121.    .macro print
  122.       .if %0=1
  123.          putc  %1,155
  124.       .else
  125. @3       .= @p1 ! @p2 ! @p3
  126.          .if %0 > 3
  127. @3          .= %4
  128.          .else
  129.             .if %0 = 2
  130. @3             .= @3 ! @s2
  131.             .endif
  132.          .endif
  133.          .if @3 & @s2
  134.             jmp  *+%2+3
  135.             .byte %$2
  136.             _io %1,*-%2,%2,[@3 & @special] ! [@3 & @p1] ! @p2 ! @p3,print
  137.          .else
  138.             _io %1,%2,%3,@3,print
  139.          .endif
  140.       .endif
  141.    .endm
  142.  
  143.    .macro input
  144. @3    .= @p1 ! @p2 ! @p3
  145.       .if %0 = 4
  146. @3       .= %4
  147.       .endif
  148.       _io %1,%2,%3,@3,input
  149.    .endm
  150.  
  151. ; -------------------------------------------------------------
  152. ; For the macro...
  153. ;              XIO  command,channel,aux1,aux2,buffer[,select]
  154. ; will get us
  155. ;     channel in X
  156. ; -------------------------------------------------------------
  157.    .macro xio
  158. @3    .= @p1 + @p2 + @p3 + @p4 + @p5
  159.       .if %0 = 6
  160. @3       .= %6
  161.       .endif
  162.       ch_x %2,[@3 & @p2]/@p2 ! [@3 & @special]
  163.       @moke_x  %1,iccom, @3
  164.       @moke_x  %3,icax1,[@3 & @p3] / @p3
  165.       @moke_x  %4,icax2,[@3 & @p3] / @p4
  166.       @dmoad   %5,[@3 & @p5] / @p5
  167.       jsr   ciov
  168.    .endm
  169.  
  170.  
  171.    .macro putc
  172. @3    .= @p1 + @p2
  173.       .if %0 = 3
  174. @3       .= %3
  175.       .endif
  176.       ch_x     %1, @3
  177.       @moad    %2,[@3 & @p2] / @p2,@y
  178.       jsr      putc
  179.    .endm
  180.  
  181.    .macro getc
  182. @3    .= @p1
  183.       .if %0 = 2
  184. @3       .= %2
  185.       .endif
  186.       ch_x     %1, @3
  187.       jsr      getc
  188.    .endm
  189.  
  190.    .endif
  191.  
  192.  
  193.