.TITLE GETBLK .ident /hah015/ ; ; Written: 16-Aug-85 hah015 ; Expand task if $RQCB fails. ; ; This routine calls $RQCB for the caller and returns if no errors. If there ; is an error, then it tries to expand the task by 1KW and, if successfull, ; calls $RQCB again. Otherwise, it prints an error message and exits. ; .psect code,ro .mcall gtsk$s, extk$s getblk:: mov r2,-(sp) ;Save arguments in case need to call $RQCB again mov r1,-(sp) mov r0,-(sp) ; 4(sp) r2 ; 2(sp) r1 - length or -length ; 0(sp) r0 - freehd pointer 10$: call $rqcb ;Try to get a block. bcc 100$ ;Worked, done sub #40,sp ;Room for task information mov sp,r0 ;Point to block gtsk$s r0 ;Get the information mov g.tsts(r0),r1 ;Get task size (data size if I/D) add #40,sp ;Clear stack bic #3,r1 ;Reduce to last 2-word boundary mov r1,-(sp) ;Save task ending address ; 6(sp) r2 ; 4(sp) r1 - length or -length ; 2(sp) r0 - freehd pointer ; 0(sp) Ending address of task neg r1 ;Amount of space available mov #2048.,r2 ;Amount of memory to request cmp r2,r1 ;Enough memory left? bhis 20$ ;No, reduce request to length of task remaining mov r2,r1 ;Yes, ask for complete 1KW br 40$ ;Skip next check 20$: mov 4(sp),r2 ;Get user requested length bpl 30$ ;Have actual length wanted neg r2 ;Convert to actual length wanted 30$: cmp r2,r1 ;Enough memory left to satisfy user? blos 40$ ;Requesting enough memory trap nomem ;Abort with memory error 40$: add #63.,r1 ;Round up to next 32. word boundary bic #63.,r1 ;Clear extra bits mov r1,-(sp) ;Save length of request ;10(sp) r2 ; 6(sp) r1 - length or -length ; 4(sp) r0 - freehd pointer ; 2(sp) Ending address of stack ; 0(sp) Length of extention asked for ash #-6,r1 ;Convert request to 32. word increment extk$s r1 ;Extend the task if possible bcc 50$ ;Worked trap nomem ;Abort 50$: mov (sp)+,r1 ;Length we just extended task mov (sp)+,r2 ;Starting address of extention mov @sp,r0 ;Get listhead address call $rlcb ;Add to list of free memory mov @sp,r0 ;Get listhead back mov 2(sp),r1 ;Get length wanted back mov 4(sp),r2 ;Get r2 back br 10$ ;Try again 100$: cmp (sp)+,(sp)+ ;Clean stack tst (sp)+ clc ;Done return ;Bye .end