Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ bitszbo(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                              bitszbo(3C)



        _________________________________________________________________
        bitszbo                                                  function
        Set a bit to 1 and return the bit's previous value.
        _________________________________________________________________


        Calling Sequence

        #include <bit.h>
        $asm int bitszbo();
        short *ptr;
        int offset, value;
        value = bitszbo(ptr, offset);


        Description

        The bitszbo function sets to 1 the bit specified by a word
        pointer, ptr, and a non-negative bit offset, offset, and then
        returns the bit's previous value.  Note that the most significant
        bit in the 16-bit word pointed to by ptr is at offset 0, and the
        least significant bit is at offset 15.  If the offset is
        negative, the bitszbo routine may cause an error.

        Because it works in one effective memory cycle, the bitszbo
        function can be used between tasks to set flag bits.

        Since this function is declared with the $asm calling sequence,
        make sure you declare it properly with $asm or use the include
        file bit.h.  The include file bit.h defines this function.


        Returns

        The bitszbo function returns 0 or 1 depending on whether the
        addressed bit was previously 0 or 1.


        Related Functions

        See also the bitvalue and bitset functions.


        Example

        /* Program test for the bitszbo() function */

        #include <bit.h>
        #include <stdio.h>





        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                              bitszbo(3C)



        short s, bit15, bit0;

        main() {
            s = 3;                       /* bits 15 & 14 are 1 */
            bit0 = bitszbo(&s, 0);       /* set bit 0 to 1 */
            bit15 = bitszbo(&s, 15);     /* set bit 15 to 1 */
            (void) printf("s = %hx (hexadecimal)\n", s);
            (void) printf("bit0 = %d\n", bit0);
            (void) printf("bit15 = %d\n", bit15);
        }

        The above program produces the output

        s = 8003 (hexadecimal)
        bit0 = 0
        bit15 = 1






































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026