.NLIST TOC,SYM .TITLE $ALBLK .SBTTL ULBLIB 025 - Allocate Block .IDENT \V01.00\ .PSECT .LIBC. .ENABL LC,GBL ; 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. ;+ ; $ALBLK ; This routine determines whether a block of memory storage can be ; allocated from the free dynamic memory. If so, it clears the allocated ; block and return the resident memory address of the block. If there is ; insufficient space in the free dynamic memory, the user routine $ERMSG ; is entered with E$R4 in R1 and $FRHD in R2. ; ; R1 = number of bytes to be allocated (<=512.) ; ; CALL $ALBLK ; ; R0 = dynamic memory address of the cleared block. ; R1 = 0 ; R2 = random ; ; If unsuccessful, $ERMSG is jumped to with ; R1 = E$R4 ; R2 = $FRHD ;- $ALBLK:: MOV R1,-(SP) ;Save the size CALL $GTCOR ;Request a block of storage BCC 10$ ;Branch if successful MOV #E$R4,R1 ;R1 = error code MOV #$FRHD,R2 ;R2 -> free memory list head JMP $ERMSG ;Issue fatal error (no return) 10$: MOV (SP)+,R1 ;Restore the size of the request ADD #3,R1 ;Round to next 2 word boundary BIC #3,R1 ;Clear ugly bits ASR R1 ;Get size in words MOV R0,R2 ;Copy address of block 2$: CLR (R2)+ ;Clear block DEC R1 ;Decrement the count BNE 2$ ;Loop RETURN .END