.TITLE LIB_LOCKS Set/clear interlock bits .IDENT /V01.01/ ;++LIBLOCKS.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Routines ; ; Abstract: ; Provide High Level Language access to the BBCCI and BBSSI instructions ; (Branch on bit set/clear and set/clear, interlocked). ; ; Environment: ; Module stored in FERMILIB.OLB and linked in users' programs. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 28-Sep-82 ; ; V01.00 28-Sep-82 FJN Created ; V01.01 15-Apr-83 FJN Standardize help text in headers ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; ; NONE ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; bitno = 4 ;Argument offset to bit number bits = 8 ;Argument offset to address of bit ; string. ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE LIB_CLR_LOCK Clear interlock bit and return previous value ;+0LIB_CLR_LOCK ; ; Functional Description: ; Clear an interlock bit in the bit string and return the previous ; value of the bit. ; ; Calling Sequence: ; value.wlu.v = LIB_CLR_LOCK( bitno.rl.r,bits.mv.r ) ; ; Input Parameters: ; bitno - address of a longword containing the number of the bit to be ; cleared. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; value - previous value of specified bit returned as TRUE (-1) if the ; bit was set or FALSE (0) if the bit was clear. ; bits - address of the base byte of the bit string (or array). The ; bit specified in bitno is modified. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; Bit is cleared using the interlocked instruction. ; ;- ;+ LIB_CLR_LOCK ; Clears an interlock bit in the bit string and returns the previous ; value of the bit. ; ; value.wlu.v = LIB_CLR_LOCK( bitno.rl.r, bits.mv.ra ) ; ; value previous value of specified bit returned as TRUE (-1) if the ; bit was set or FALSE (0) if the bit was clear. Passed by ; value. ; ; bitno longword containing the number of the bit to be cleared. ; Passed by reference. ; ; bits first byte of the bit string (or array). The bit specified ; by bitno is modified. Passed by reference. ;- .ENTRY LIB_CLR_LOCK,^M<> CLRL R0 ;Assume bit clear now BBCCI @bitno(AP),@bits(AP),9$ ;Clear bit and skip if already cleared MNEGL #1,R0 ;Bit was set, return -1. 9$: RET .PAGE .SUBTITLE LIB_SET_LOCK Set interlock bit and return previous value ;+0LIB_SET_LOCK ; ; Functional Description: ; Set an interlock bit in the bit string and return the previous ; value of the bit. ; ; Calling Sequence: ; value.wlu.v = LIB_SET_LOCK( bitno.rl.r,bits.mv.r ) ; ; Input Parameters: ; bitno - address of a longword containing the number of the bit to be ; set. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; value - previous value of specified bit returned as TRUE (-1) if the ; bit was set or FALSE (0) if the bit was clear. ; bits - address of the base byte of the bit string (or array). The ; bit specified in bitno is modified. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; Bit is set using the interlocked instruction. ; ;- ;+ LIB_SET_LOCK ; Sets an interlock bit in the bit string and returns the previous ; value of the bit. ; ; value.wlu.v = LIB_SET_LOCK( bitno.rl.r, bits.mv.ra ) ; ; value previous value of specified bit returned as TRUE (-1) if the ; bit was set or FALSE (0) if the bit was clear. Passed by ; value. ; ; bitno longword containing the number of the bit to be set. ; Passed by reference. ; ; bits first byte of the bit string (or array). The bit specified ; by bitno is modified. Passed by reference. ;- .ENTRY LIB_SET_LOCK,^M<> MNEGL #1,R0 ;Assume bit is now set BBSSI @bitno(AP),@bits(AP),9$ ;Set bit and skip if already set CLRL R0 ;Bit was initially cleared 9$: RET .END