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 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 NULL operand - should abort
    BitVecOr(&result, &bv1, NULL);
    
    BitVecDeinit(&result);
    // 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

BitVecReplaceAll

BitVecReplaceAll Description Replace all occurrences of old pattern with new pattern.

Read More

BitVecReplace

BitVecReplace Description Replace first occurrence of old pattern with new pattern.

Read More

BitVecPrefixMatch

BitVecPrefixMatch Description Match bitvector against an array of prefix patterns. Returns the index of the first matching prefix.

Read More