1 /** Swap test using 'addition' instead of usual 'or'
12 swap_add_8(uint8_t value
)
14 value
= (value
<< 4) + (value
>> 4);
18 #define SWAP_ADD_8(value) (((value << 4) & 0xF0u) | ((value >> 4) & 0x0Fu))
19 #define SWAP_ADD_8_EQUALS(value) (swap_add_8(value) == SWAP_ADD_8(value))
23 #ifndef __SDCC_pdk15 // Bug
24 ASSERT(SWAP_ADD_8_EQUALS(0x01));
25 ASSERT(SWAP_ADD_8_EQUALS(0x02));
26 ASSERT(SWAP_ADD_8_EQUALS(0x04));
27 ASSERT(SWAP_ADD_8_EQUALS(0x08));
29 ASSERT(SWAP_ADD_8_EQUALS(0x10));
30 ASSERT(SWAP_ADD_8_EQUALS(0x20));
31 ASSERT(SWAP_ADD_8_EQUALS(0x40));
32 ASSERT(SWAP_ADD_8_EQUALS(0x80));
34 ASSERT(SWAP_ADD_8_EQUALS(0x0F));
35 ASSERT(SWAP_ADD_8_EQUALS(0xF0));
36 ASSERT(SWAP_ADD_8_EQUALS(0x3C));
37 ASSERT(SWAP_ADD_8_EQUALS(0xC3));