Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Relate Structure variables?
  2. struct RSI
  3. {
  4.      int RSI;
  5.      int ESI = RSI & 0x1F;
  6.      int SI = ESI & 0x0F;
  7.      int SIL = SI & 0x08;
  8. };
  9.        
  10. struct RSI
  11. {
  12. private:
  13.     int rsi;
  14.  
  15. public:
  16.     RSI(int rsi) : rsi(rsi) {}
  17.  
  18.     int getRSI() const { return rsi; }
  19.     int getESI() const { return getRSI() & 0x1F; }
  20.     int getSI()  const { return getESI() & 0x0F; }
  21.     int getSIL() const { return getSI()  & 0x08; }
  22. };
  23.        
  24. union RSI_t
  25. {
  26.     int RSI;
  27.     int ESI : 5;
  28.     int SI : 4;
  29.     int SIL : 3;
  30. };
  31.        
  32. #include <stdint.h>
  33.  
  34. union RAX_t
  35. {
  36.     uint64_t RAX;
  37.     uint32_t EAX;
  38.     uint16_t AX;
  39.     struct {
  40.         uint8_t AL;
  41.         uint8_t AH;
  42.     };
  43. };