.TITLE LRecev Aleda Initiate Receive .PSECT Aleda,Con,Gbl .Dsabl GBL ;;********************************************************************** ;; Fortran callable subroutine to initiate the transfer of characters ;; from the specified Alvin unit # to an Alvin circular buffer. ;; ;; Supports calls of the form: ;; Ierror = LRecev ( Unit #, Buffer, Buffer Size, Return Code, ;; c Control Word ) ;; ;; Note: If the buffer size is zero, the buffer will be ;; presumed to be initialized already. If positive, it will specify ;; that the buffer descriptor should be constructed based on this size. ;;********************************************************************** ;; Last Modified: 8-May-84 DVJensen ;; 16-Jul-85 - Implement CONTROL WORD to allow receipt with NO_ECHO. ;; and BUFFER_RESET (this will flush a buffer). ;; 7-Oct-85 - Compatability with RT Carry Set error indication. ;;********************************************************************** ;; .Mcall $Alv51 .Globl Receive,GetParm,GetDDA ;External Globals $Alv51 ;; Control Word Bits - If set they indicate: ;;********************************************************************** LRecev:: MOV R5,-(SP) ;SAVE REGISTERS USED MOV R4,-(SP) MOV R3,-(SP) MOV R2,-(SP) MOV R1,-(SP) Clr Return ;Initialize Variables ;Fortran Calling Convention: Clr R0 ;Set for counting the parameters Mov (R5)+,R1 ;Get number of parameters passed. Bic #177400,R1 ;Clear possible high order junk Jsr PC,GetParm ;Get Parm # 1: Logical Unit number. Bcs RcvError ;Required Parm - Abort if not provided. Mov (R4),R3 ;Get the actual unit number Mov R3,Unit ;Save it Clr Buffer ;Default buffer descriptor to zero. Jsr PC,GetParm ;Get Parm # 2: Circular Buffer. Bcs Getp3 ;Optional Parm - Continue if not provided. Mov R4,Buffer ;Save pointer to the buffer region. Ror R4 ;Check buffer for word allignment Bcc Getp3 ;Branch if ok Mov #31.,R0 ;Error code #31. - buffer not word alligned. Br RcvError Getp3: Clr Bufsize ;Default buffer size to zero. Jsr PC,GetParm ;Get Parm # 3: Circular Buffer Size. Bcs Getp4 ;Optional Parm - continue if not provided. Mov (R4),R2 Mov R2,BufSize ;Save the SIZE. Beq Getp4 ;If zero, presume buffer is already set. Cmp R2,#20. ;Check to see it is big enough Bhis Getp4 ;Must be at least 20 bytes big - branch if ok. Mov #30.,R0 ;Set error code Br RcvError ;Return error code #30. Getp4: Jsr PC,GetParm ;Get Parm # 4: Return Code Location. Bcs Getp5 ;Continue if not available (defaulted above) Mov R4,Return ;Save the address to return the code to. Getp5: Clr Control ;Default Control Word to zero (optional). Jsr PC,GetParm ;Get Parm # 5: Control Word. Bcs Getp6 ;Continue if not available Mov (R4),Control ;Save the Control Word value. Bic #^C,Control ;Allow only these bits. Getp6: Br RcvGO ;;**************************** RcvError: ; Error occurred - Code is in R0 Neg R0 ;Force return value negative Sec ; to indicate error Jmp RcvRtn ; and Return. ;;**************************** ;; RcvGO: Jsr R5,GetDDA ;Get the Device Descriptor Address .Word -1 ;Requested unit is already in Register 3. Tst R0 ;Check if this was a valid unit number Bne RcvBD ;Proceed if non-zero. Rcv1Err: Mov #20.,R0 ;Return Error Code #20. - No Descriptor. Br RcvError ;Return error. RcvBD: Mov R0,R2 ;Save the Device Desc Address. Bit #Disabled,(R2) ;Is this device currently disabled? Beq Rcv100 ;No, branch - OK receive from it. Mov #21.,R0 ;Yes, return error #21. Br RcvError Rcv100: Mov Buffer,R4 ;Get the user supplied buffer address Bne Rcv110 ;Branch if it is not zero - user provided it. Mov BDefault(R2),Buffer ;Use the Default buffer. Bne Rcv139 ; If non-zero, then default buf exists. Mov #37.,R0 ;Cannot initiate input: NO BUFFER - error #37. Br RcvError ; Return Error. Rcv110: Mov BufSize,R1 ;Get the size of the buffer Beq Rcv139 ;Branch if zero - buffer is already init'ed. Mov R4,R0 ;Start of the buffer descriptor. Add R0,R1 ;End address of the buffer ( +1 ) Dec R1 ; actual end address of the buffer. Add #12.,R0 ;Actual Start of character storage. Mov R0,(R4)+ ;Input pointer Mov R0,(R4)+ ;Output pointer Mov R0,(R4)+ ;Start address of buffer Mov R1,(R4)+ ;End Address of buffer Clr (R4) ;Buffer Status Rcv139: Mov Buffer,R4 ;Get the buffer to be used. Mov Unit,R3 ;Get the unit to receive from. Bis Control,R3 ;Allow user to specify RECEIVE functions. Jsr R5,Receive ;Have Alvin initiate the Receive. .Word -1 ;Unit and Function(s) are in Reg 3. .Word 0 ;Buffer is in Reg 4. Br RcvProblem ;Could not initiate - Return an error. Clr R0 ;Success - return code=R0=Zero. Carry clear. Br RcvRtn ;;******************************* RcvProblem: Mov #29.,R0 ;Receive failure to initiate - Error #29. Br RcvError ;;**************************** RcvRtn: Mov Return,R1 ; Did the user specify to return the code? Beq RcvExit ; No, exit. Mov R0,(R1) ; Return error code to user. Preserve Carry. RcvExit: MOV (SP)+,R1 MOV (SP)+,R2 MOV (SP)+,R3 MOV (SP)+,R4 MOV (SP)+,R5 RTS PC ;AND RETURN ;;**************************** Unit: .Word 0 ;Unit number to Receive from. Buffer: .Word 0 ;Address of User's Circular Buffer. BufSize: .Word 0 ;Size of the Circular Buffer. Return: .Word 0 ;Address of User's Location for Return Code. Control: .Word 0 ;User specified control word. ;;************************************************************************** .END