Skip to content

BitVecXor

BitVecXor

Description

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

Parameters

Name Direction Description
result out Bitvector to store result in
a in First bitvector operand
b in Second bitvector operand

Usage example (from documentation)

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

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void BitVecXor(BitVec *result, BitVec *a, BitVec *b) {
        ValidateBitVec(result);
        ValidateBitVec(a);
    
        // Test NULL second operand - should abort
        BitVecXor(&result, NULL, &bv1);
    
        BitVecDeinit(&result);
    // 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 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);
Last updated on