BitVecOr

Table of Contents

BitVecOr

Description

Perform bitwise OR operation between two bitvectors. Result is stored in the first bitvector.

Parameters

NameDirectionDescription
resultoutBitvector to store result in
ainFirst bitvector operand
binSecond bitvector operand

Usage example (from documentation)

  BitVecOr(&result, &flags1, &flags2);

Usage example (Cross-references)

    }
    
    void BitVecOr(BitVec *result, BitVec *a, BitVec *b) {
    ValidateBitVec(result);
    ValidateBitVec(a);
    
    // Test NULL operand - should abort
    BitVecOr(&result, &bv1, NULL);
    
    BitVecDeinit(&result);
    // Test BitVecOr function
    bool test_bitvec_or(void) {
    WriteFmt("Testing BitVecOr\n");
    
    BitVec bv1    = BitVecInit();
    
    // Perform OR operation
    BitVecOr(&result, &bv1, &bv2);
    
    // Expected result: 1110 (1100 OR 1010)
    result = result && (result_bv.length == 0);
    
    BitVecOr(&result_bv, &bv1, &bv2);
    result = result && (result_bv.length == 0);
    
    // Test OR with different lengths (result should be max length)
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    test_result = test_result && (BitVecGet(&result, 0) == false);
    
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (BitVecGet(&result, 0) == true);
    
    // Test A OR A = A
    BitVecOr(&result, &bv1, &bv1);
    bool or_identity = true;
    for (int i = 0; i < 16; i++) {
    }
    
    BitVecOr(&result, &bv1, &bv2);
    bool or_ones = true;
    for (int i = 0; i < 16; i++) {
    
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    
    bool or_commutative = true;
    // Test BitVecOr function
    bool test_bitvec_or(void) {
    WriteFmtLn("Testing BitVecOr");
    
    BitVec bv1    = BitVecInit();
    
    // Perform OR operation
    BitVecOr(&result, &bv1, &bv2);
    
    // Expected result: 1110 (1100 OR 1010)
    result = result && (result_bv.length == 0);
    
    BitVecOr(&result_bv, &bv1, &bv2);
    result = result && (result_bv.length == 0);
    
    // Test OR with different lengths (result should be max length)
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    test_result = test_result && (BitVecGet(&result, 0) == false);
    
    BitVecOr(&result, &bv1, &bv2);
    test_result = test_result && (BitVecGet(&result, 0) == true);
    
    // Test A OR A = A
    BitVecOr(&result, &bv1, &bv1);
    bool or_identity = true;
    for (int i = 0; i < 16; i++) {
    }
    
    BitVecOr(&result, &bv1, &bv2);
    bool or_ones = true;
    for (int i = 0; i < 16; i++) {
    
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    // Test A OR B = B OR A
    BitVecOr(&result1, &bv1, &bv2);
    BitVecOr(&result2, &bv2, &bv1);
    
    bool or_commutative = true;
    
    // Test NULL operand - should abort
    BitVecOr(&result, &bv1, NULL);
    
    BitVecDeinit(&result);

Share :

Related Posts

BitVecDisjoint

BitVecDisjoint Description Check if two bitvectors are disjoint (have no common 1-bits).

Read More

BitVecAnd

BitVecAnd Description Perform bitwise AND operation between two bitvectors. Result is stored in the first bitvector.

Read More

BitVecIsSorted

BitVecIsSorted Description Check if bits in bitvector are in sorted order. Useful for certain algorithms and data structures.

Read More