daily pastebin goal
66%
SHARE
TWEET

UNIA_XOR

olgierd Dec 10th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef union {
  2.         unsigned char  BYTE;
  3.         struct {
  4.             unsigned char a : 2;
  5.             unsigned char b : 3;
  6.             unsigned char c : 3;
  7.         }bits;
  8.     }un_X;
  9.  
  10.     un_X x;
  11.  
  12.     x.BYTE = 0xAF; // 175(dec)
  13.     ///UNIE
  14.     // a.bits.b = a.bits.a ^ 3;
  15.     //a.bits.c = a.bits.a^3;
  16.     bitset<8> wynik(x.BYTE);
  17.     cout << wynik<<endl;
  18.     unsigned char wynik2;
  19.     _asm {
  20.         mov al, x.bits
  21.         and al,0x03
  22.         xor al,0x03
  23.         mov bl,al
  24.         shl al,3
  25.         and al,0x18
  26.         shl bl,5
  27.         and bl,0x60
  28.         or al,bl
  29.         or x.bits,al
  30.         mov wynik2,al
  31.     }
  32.     bitset<8> eldo(wynik2);
  33.     cout << eldo<< endl;
  34.    
  35.    
  36.     printf("BYTE: %d\n x.bits.a: %d\n x.bits.b: %d\n x.bits.c: %d\n", x.BYTE, x.bits.a, x.bits.b, x.bits.c);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top