.title lunsub ;+ ; this pair of routines implement the following fortran interfaces ; ; integer function getlun() ; subroutine putlun(logical_unit) ; ; they permit the programmer to request free luns and to ; return them when he is done with them. The domain of these ; routines is the set of luns in the range [ 9 , .NLUNS ] ; where .NLUNS is the value given to TKB as UNITS=nnn ;- ap=%5 lun=2 err=-3 ; error return if no luns available ; ; lun = getlun() ; .psect $r.roi,con,ro,rel,lcl,i .enabl lsb getlun:: r$glun:: call r$savr ; save all registers mov #9.,r0 ; starting lun number mov .nluns,r1 ; limiting event flag number mov #r$lunm,r2 ; address of lun mask mov #400,r3 ; initial mask bit call allbit ; get a free lun bcc 10$ ; c clear => successful mov #err,r0 ; return(ERR) 10$: mov r0,2(sp) ; cause value to be returned return ; ; subroutine putlun(lun) ; putlun:: mov @lun(ap),r0 ; get LUN to return r$plun:: call r$savr ; save all registers cmp r0,#9. ; can user free this lun? blt 20$ ; NO mov .nluns,r1 ; limiting LUN number mov #r$lunm,r2 ; starting address of mask mov #1,r3 ; initial mask bit call frebit ; free the bit 20$: return .end