Exemple #1
0
void swap(int* tmp, int index, int cur, int pre)
{
        if(cur == pre)
        {
                return;
        }
        updateBit(tmp, index, pre);
        updateBit(tmp, index - 1, cur);

}
void test_bitTasks()
{
	assert(getBit(4,1) == 0);
	assert(getBit(4,2) == 1);

	assert(setBit(4,1) == 6);
	assert(setBit(4,2) == 4);

	assert(clearBit(4,1) == 4);
	assert(clearBit(4,2) == 0);

	assert(updateBit(4,1,0) == 4);
	assert(updateBit(4,2,1) == 4);
}
void updateCPSR(bool bit, unsigned int bitnum) {
    if (bitnum > Nbit || bitnum < Vbit) {
        fprintf(stderr, "%s. bitnum = %d",
                "updateCPSR bitnum value is not in range", bitnum);
        exit(2);
    }

    CPSR = updateBit(CPSR, bitnum, bit);
}
Exemple #4
0
void insertNumBit(int N, int M)
{
        if(N < M)
        {
                printf("N should bigger than M\n");
                return;
        }
        int num = M;
        int cnt = 0;
        while( num != 1 )
        {
                int bit = num % 2;
                updateBit(&N, cnt++, bit);
                num = num / 2;
        }
        updateBit(&N, cnt++, 1);
        printf("After inserting:(M,N) = (%d,%d)\n", M, N);
}
Exemple #5
0
/**
 * Write a single bit
 */
bool Eeprom::writeBit(int address, uint8_t bit, bool value)
{
    updateBit(address, bit, value);
    return true;
}
bool EEPROMClassEx::writeBit(int address, uint8_t bit, bool value) {
	updateBit(address, bit, value);
	return true;
}