;
;       NAME:  BLKINP.M68                     The House of Representatives
;                                             Written by Tan Nguyen
;                                             date Sept 20, 1985
;
       OBJNAM  .SBR
;
;       FUNCTION:  handles block input from Teleray crt
;
;       CALLING SEQUENCE:
;       ----------------
;       XCALL BLKINP,BUFFER,LENGTH   where
;
;       BUFFER  Any     This is where the characters are returned.  The
;                       size of this field implies the maximum # of
;                       bytes that can be returned.
;       LENGTH  Float   The # of characters received is returned in this
;                       field.(excluding blank)
;
;
;       EDIT HISTORY:
;       ------------       by tan nguyen Sept 20, 1985
;
; **************************************************************************
; MAINTENANCE NOTE:
; ----------------     more options will be added to accomodate with
;                      the EVS requirement as we go along..TAN NGUYEN
;
; **************************************************************************
       PAGE




       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  TRM

;
; XCALL argument equates
;
       XC.ARG=0                ;number of arguments (0-1)
       XC.TYP1=2               ;argument #1 - type  (2-3)
       XC.ADR1=4               ;argument #1 - address(4-7)
       XC.SIZ1=8.              ;argument #1 - size   (8-11)
       XC.TYP2=12.             ;argument #2 - type   (12-13)
       XC.ADR2=14.             ;argument #2 - address (14-17)
       XC.SIZ2=18.             ;argument #2 - size    (18-21)
;
;
       VMAJOR=1
       VMINOR=0
       VEDIT=0

BLKINP: PHDR    -1,PV$RSM!PV$WSM,PH$REU!PH$REE
       CMPW    (A3),#2         ; must be exactly two args
       JNE     RETURN                  ; die if not.
       LEA     A2,4(A3)                ; get address buffer
       MOV     (A2),A0                 ; A0 -> buffer
       MOV     8.(A3),D2               ; D2 = length of buffer
       DEC     D2                      ; D2 = length of buffer - 1
       MOVW    12.(A3),D6              ; test type of last arg
       ANDW    #7,D6                   ; must be float
       CMPW    D6,#4
       JNE     RETURN
       MOV     D2,D6                   ; D6 = length of buffer - 1
       MOV     A0,A6                   ; A6 -> buffer
CLEAR:  MOVB    #'*,(A6)+               ; clear out return buffer
       DBF     D6,CLEAR
       CLR     D4                      ; D4 is chars. of a line
       CLR     D3                      ; D3 used to count chars received

       JOBIDX  A6                      ; keep address of trmdef in A5
       MOV     JOBTRM(A6),A5

;**********************************************************************
;       This routine just waits until the caller's buffer is full.
;**********************************************************************
BLKMOV:
       KBD
       CMPB    D1,#6                   ; if end of text?
       BEQ     EOT1                    ; YES  stop
       CMPB    D1,#15                  ; IF a cr.
       BEQ     RESET                   ; yes then reset
       CMPB    D1,#12                  ; if a linefeed
       BEQ     BLKMOV                  ; yes. ignore it
GOTCHR: MOVB    D1,(A0)+                ; store it,
       INC     D3                      ; increment counter,
       INC     D4
       BR      BLKMOV
RESET:
       SUB     #80.,D4                 ;
       NEG     D4
FILL:   TSTB    (A0)+
       DBF     D4,FILL
       CLR     D4
       BR      BLKMOV
;
;       Store character count and return.
;
EOT1:   MOV     14.(A3),A0              ; A0 -> length variable
       FLTOF   D3,@A0                  ; store counter...
RETURN: RTN
       END