qdosmsq:traps:trap_3:flin

IO_FLINE/IOB_FLIN & IO_FSTRG/IOB_FMUL

These traps read a set of bytes from a channel.

Call ParametersReturn Parameters
D0.B$02 or $03D0.LError code.
D1.L D1.WNumber of bytes fetched.
D2.WLength of buffer. D2.LPreserved.
D3.WTimeout.D3.LPreserved.
A0.LChannel ID A0.LPreserved.
A1.LPointer to buffer.A1.LPointer to one byte after the last fetched.
ERR_NCNot complete.
ERR_NOChannel not open.
ERR_EFEnd of file.
ERR_BOBuffer overflow.
  • All registers not shown above are not used on entry and are preserved on exit.
  • D0.B is $02 for IO_FLINE/IOB_FLIN and $03 for IO_FSTRG/IOB_FMUL.
  • IO_FLINE/IOB_FLIN fetches a line of bytes ending with LF ($0A). The LF is included as the last character fetched. If the number of bytes read before LF is reached exceeds the size of the buffer a buffer overflow error occurs.
  • IO_FSTRG/IOB_FMUL reads the number of bytes specified in D2.W unless EOF is reached first.
  • If bytes are being read from a CON channel the actions of the two Traps are different. For IO_FLINE/IOB_FLIN the cursor is enabled and the characters are mirrored in the window. Also the arrow keys can be used to edit the line in the normal way. For IO_FSTRG/IOB_FMUL the characters are not printed in the window and any cursor handling is up to the application.
input   moveq   #io_fstrg,d0
        moveq   1024,d2                 ; Buffer max size
        moveq   #-1,d3                  ; Infinite timeout
        lea     input_buffer,a1         ; Read data into here
        move.l  a1,-(a7)                ; Save buffer address
        trap    #2
        cmpi.w  #ERR_EF,d0              ; EOF?
        beq.s   input_end               ; Yes
        tst.w   d0                      ; Any other error?
        bne.s   input_end               ; Yes
        
input_end
        move.l  (a7)+,a1                ; Restore buffer
        rts                             ; D0 = error code, ERR_EF or zero
        
input_buffer
        ds.w    1
        ds.b    1024
  • qdosmsq/traps/trap_3/flin.txt
  • Last modified: 2018/10/19 14:10
  • by norman