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) {
    printf("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) {
    printf("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);

Share :

Related Posts

BitVecAnd

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

Read More

BitVecEntropy

BitVecEntropy Description Calculate information entropy of a bitvector. Entropy measures the randomness/information content of the bit pattern.

Read More

BitVecOr

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

Read More