#include #define STRSTR( x ) #x #define STR( x ) STRSTR( x ) #define PnX(x) \ for ( ;; ) \ { \ fprintf (stderr, "x: %-56s res: ", STR ( x; )); \ x; \ break; \ } volatile int a = 0x55aa55aa; volatile int b = 0xff00ff00; int main ( int argc, char** argv ) { int c; fprintf ( stderr, " %-61s a: 0x%08x b: 0x%08x\n", "--init--", a, b ); PnX (a ^= ( b^= ( a ^= b ))); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); /** * volatile weg-gecastet (nützt im Assembler nix, schad' aber auch nix) */ PnX (((int) a ) ^= (((int) b )^= (((int) a ) ^= ((int) b )))); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); /** * volatile weg-gecastet (aber jetzt nützt's was) */ { int c = a; int d = b; PnX (c ^= ( d^= ( c ^= d ))); a = c; b = d; } fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); PnX (a ^= b; b ^= a; a ^= b); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); PnX (c = a; a = b; b = c); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); PnX (b = ( a ^ b ) ^ ( a = b )); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); PnX (b = ( a = b ) ^ ( a ^ b )); fprintf ( stderr, "a: 0x%08x b: 0x%08x\n", a, b ); exit ( 0 ); }