BitVecXor

Table of Contents

BitVecXor

Description

Perform bitwise XOR 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)

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

Usage example (Cross-references)

    }
    
    void BitVecXor(BitVec *result, BitVec *a, BitVec *b) {
    ValidateBitVec(result);
    ValidateBitVec(a);
    // Test BitVecXor function
    bool test_bitvec_xor(void) {
    WriteFmt("Testing BitVecXor\n");
    
    BitVec bv1    = BitVecInit();
    
    // Perform XOR operation
    BitVecXor(&result, &bv1, &bv2);
    
    // Expected result: 0110 (1100 XOR 1010)
    
    // Test XOR with different lengths
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    
    // Test A XOR A = 0
    BitVecXor(&result, &bv1, &bv1);
    test_result = test_result && (result.length == 16);
    for (int i = 0; i < 16; i++) {
    
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    
    bool xor_commutative = true;
    
    // Test XOR on large data
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 1000);
    
    // Test NULL second operand - should abort
    BitVecXor(&result, NULL, &bv1);
    
    BitVecDeinit(&result);
    // Test BitVecXor function
    bool test_bitvec_xor(void) {
    WriteFmtLn("Testing BitVecXor");
    
    BitVec bv1    = BitVecInit();
    
    // Perform XOR operation
    BitVecXor(&result, &bv1, &bv2);
    
    // Expected result: 0110 (1100 XOR 1010)
    
    // Test XOR with different lengths
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 8);
    
    // Test A XOR A = 0
    BitVecXor(&result, &bv1, &bv1);
    test_result = test_result && (result.length == 16);
    for (int i = 0; i < 16; i++) {
    
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    // Test A XOR B = B XOR A
    BitVecXor(&result1, &bv1, &bv2);
    BitVecXor(&result2, &bv2, &bv1);
    
    bool xor_commutative = true;
    
    // Test XOR on large data
    BitVecXor(&result, &bv1, &bv2);
    test_result = test_result && (result.length == 1000);
    
    // Test NULL second operand - should abort
    BitVecXor(&result, NULL, &bv1);
    
    BitVecDeinit(&result);

Share :

Related Posts

BitVecAnd

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

Read More

BitVecFuzzyMatch

BitVecFuzzyMatch Description Fuzzy pattern matching allowing up to N mismatches. Useful for approximate pattern matching with error tolerance.

Read More

BitVecReplace

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

Read More