.TITLE LIB_BIT Set/clear/test bits in large bit array .IDENT /V01.01/ ;++LIBBITS.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Routines ; ; Abstract: ; Provide High Level Language access to large bit arrays. ; ; Environment: ; Module stored in FERMILIB.OLB and linked in users' programs. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 17-Jan-83 ; ; V01.00 17-Jan-83 FJN Created ; V01.01 15-Apr-83 FJN Standardizing help header comments ; .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_BIT Clear bit in array ;+0LIB_CLR_BIT ; ; Functional Description: ; Clear a bit in the bit array (bit string). ; ; Calling Sequence: ; CALL LIB_CLR_BIT( bitno.rl.r,bits.mv.r ) ; ; Input Parameters: ; bitno - address of a longword containing the number of the bit to be ; cleared. ; bits - address of the base byte of the bit string (or array). ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; 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: ; NONE ; ;- ;+ LIB_CLR_BIT ; Clears a bit in the bit array (string). ; ; CALL LIB_CLR_BIT( bitno.rl.r, bits.mv.ra ) ; ; 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_BIT,^M<> CLRL R0 ;Bit is to be cleared BRB BITSTO .PAGE .SUBTITLE LIB_SET_BIT Set a bit in the bit array ;+0LIB_SET_BIT ; ; Functional Description: ; Set a bit in the bit array (string). ; ; Calling Sequence: ; CALL LIB_SET_BIT( bitno.rl.r,bits.mv.r ) ; ; Input Parameters: ; bitno - address of a longword containing the number of the bit to be ; set. ; bits - address of the base byte of the bit string (or array). ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; 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: ; NONE ; ;- ;+ LIB_SET_BIT ; Sets a bit in the bit array (string). ; ; CALL LIB_SET_BIT( bitno.rl.r, bits.mv.ra ) ; ; 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_BIT,^M<> MOVL #1,R0 ;Bit is to be set BITSTO: INSV R0,@bitno(AP),#1,@bits(AP) ;Store value (0/1) of bit RET .PAGE .SUBTITLE LIB_TST_BIT Return value of bit in array ;+0LIB_TST_BIT ; ; Functional Description: ; Test the value of a bit in a bit array (string) and return its value. ; ; Calling Sequence: ; value.wlu.v = LIB_TST_BIT( bitno.rl.r,bits.rv.r ) ; ; Input Parameters: ; bitno - address of a longword containing the number of the bit to be ; tested. ; bits - address of the base byte of the bit string (or array). ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; value - value of specified bit returned as TRUE (-1) if the bit is set ; or FALSE (0) if the bit is clear. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- ;+ LIB_TST_BIT ; Tests the value of a bit in a bit array (string). ; ; value.wlu.v = LIB_TST_BIT( bitno.rl.r, bits.rv.ra ) ; ; value value of specified bit returned as TRUE (-1) if the bit is ; set or FALSE (0) if the bit is clear. Passed by value. ; ; bitno longword containing the number of the bit to be tested. ; Passed by reference. ; ; bits first byte of the bit string (or array). Passed by reference. ;- .ENTRY LIB_TST_BIT,^M<> EXTV @bitno(AP),#1,@bits(AP),R0 ;Get bit value, sign-extended! RET .END