Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Compreg.cpp 1.3 1998/04/29 22:43:31 tomz Exp $
  2. #include "compreg.h"
  3. /* Method: CompositeReg::operator DWORD()
  4. * Purpose: Performs the read from a composite register
  5. */
  6. CompositeReg::operator DWORD()
  7. {
  8. // if write-only return the shadow
  9. if ( GetRegisterType() == WO )
  10. return GetShadow();
  11. // obtain the low and high values
  12. DWORD dwLowBits = (DWORD)LSBPart_;
  13. DWORD dwHighBits = (DWORD)MSBPart_;
  14. // put high part to the proper place
  15. dwHighBits <<= LowPartWidth_;
  16. // done !
  17. return dwHighBits | dwLowBits;
  18. }
  19. /* Method: CompositeReg::operator=
  20. * Purpose: performs the assignment to a composite register
  21. */
  22. DWORD CompositeReg::operator=( DWORD dwValue )
  23. {
  24. // if a register is read-only nothing is done. This is an error
  25. if ( GetRegisterType() == RO )
  26. return ReturnAllFs();
  27. // keep a shadow around
  28. SetShadow( dwValue );
  29. // compute the mask to apply to the passed value, so it can be...
  30. DWORD dwMask = ::MakeAMask( LowPartWidth_ );
  31. // ... assigned to the low portion register
  32. LSBPart_ = dwValue & dwMask;
  33. // shift is enough to get the high part
  34. MSBPart_ = ( dwValue >> LowPartWidth_ );
  35. return dwValue;
  36. }