.MCALL .MODULE .MODULE WRBLK,VERSION=03,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL Macro definitions .MCALL .WRITW .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ;Define FDB offsets FERDF$ ;Define file service error codes DEFIN$ ;Definitions for IND files .PSECT $WRBLK .SBTTL $WRBLK - Write a block ;+ ;$WRBLK ;This routine writes the logical block to the file indicated by the ;specifed FDB. ; ;Input: R1 = Address of FDB ; R3 = Block number to write ; R4 = Address of buffer ; R5 = Size of buffer in bytes ; ;Output: R1 = ADDRESS OF FDB ; R3 = Block number writen ; R4 = Address of buffer ; C-bit set if error ;- .ENABL LSB $WRBLK::SAVE MOV F$BLKM(R1),R0 ;Get maximum block number BEQ 1$ ;Branch if zero CMP R3,R0 ;Is the block past end-of-file? BLO 1$ ;Branch if no MOV #,R0 ;File exceeds allocated space SEC ;Set C-bit for error BR 4$ ;Clean up stack and return to caller 1$: MOVB @R1,R2 ;Set up channel number .ASSUME F$CHAN EQ 0 ;F$CHAN(R1) BIT #1,R5 ;Is the length odd ? BEQ 2$ ;Branch if no MOV R4,-(SP) ;Point to last byte in record ADD R5,(SP) ; ... CLRB @(SP)+ ;Append a null byte INC R5 ;Make the length even 2$: ASR R5 ;Convert byte count to words .WRITW #EMTBLK,R2,R4,R5,R3 ;Write a block to the file BCS 3$ ;Branch if error MOV R3,F$BLKN(R1) ;Save block number MOV #,R0 ;Indicate success BR 4$ ;Clean up stack and return to caller 3$: MOV #,R0 ;Default to device full error MOV @#52,R5 ;Get device code BEQ 4$ ;Device full error MOV #,R0 ;Assume device write error DEC R5 ;Decreament error code BEQ 4$ ;Yes, hardware error MOV #,R0 ;Channel not open 4$: MOV R0,F$ERR(R1) ;Save the error code RESTOR RETURN .DSABL LSB .END