Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. value bits
  2. ----- ----
  3. T: 1 0001
  4. after bit change
  5. T: 3 0011
  6. T is true
  7. T is false
  8.  
  9. #include <iostream>
  10. #include <bitset>
  11.  
  12. using namespace std;
  13.  
  14. void set_bits_to_1(void* val){
  15. char *x = static_cast<char *>(val);
  16.  
  17. for (int i = 0; i<2; i++ ){
  18. *x |= (1UL << i);
  19. }
  20. }
  21.  
  22. int main(int argc,char *argv[])
  23. {
  24.  
  25. bool T = 3;
  26.  
  27. cout <<" value bits " <<endl;
  28. cout <<" ----- ---- " <<endl;
  29. cout <<" T: "<< T <<" "<< bitset<4>(T)<<endl;
  30.  
  31. set_bits_to_1(&T);
  32.  
  33.  
  34. bitset<4> bit_T = bitset<4>(T);
  35. cout <<"after bit change"<<endl;
  36. cout <<" T: "<< T <<" "<< bit_T<<endl;
  37.  
  38. if (T ){
  39. cout <<"T is true" <<endl;
  40. }
  41.  
  42. if ( T == false){
  43. cout <<"T is false" <<endl;
  44. }
  45.  
  46.  
  47. }
  48.  
  49. movzx eax, BYTE PTR [rbp-33]
  50. test al, al
  51. je .L22
  52.  
  53. movzx eax, BYTE PTR [rbp-33]
  54. xor eax, 1
  55. test al, al
  56. je .L23
  57.  
  58. int foo(bool b, int i) {
  59. return i + b;
  60. }
  61.  
  62. foo(bool, int):
  63. movzx edi, dil
  64. lea eax, [rdi+rsi]
  65. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement