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.

133 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. setops.c
  5. Abstract:
  6. This module implements the code to emulate set opcodes.
  7. Author:
  8. David N. Cutler (davec) 13-Sep-1994
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "nthal.h"
  14. #include "emulate.h"
  15. VOID
  16. XmSxxOp (
  17. IN PRXM_CONTEXT P
  18. )
  19. /*++
  20. Routine Description:
  21. This function emulates set byte on condition opcodes.
  22. Arguments:
  23. P - Supplies a pointer to the emulation context structure.
  24. Return Value:
  25. None.
  26. --*/
  27. {
  28. ULONG Complement;
  29. ULONG Condition;
  30. //
  31. // Case on the set control value.
  32. //
  33. Complement = P->SrcValue.Long & 1;
  34. switch (P->SrcValue.Long >> 1) {
  35. //
  36. // Set if overflow/not overflow.
  37. //
  38. case 0:
  39. Condition = P->Eflags.EFLAG_OF;
  40. break;
  41. //
  42. // Set if below/not below.
  43. //
  44. case 1:
  45. Condition = P->Eflags.EFLAG_CF;
  46. break;
  47. //
  48. // Set if zero/not zero.
  49. //
  50. case 2:
  51. Condition = P->Eflags.EFLAG_ZF;
  52. break;
  53. //
  54. // Set if below or equal/not below or equal.
  55. //
  56. case 3:
  57. Condition = P->Eflags.EFLAG_CF | P->Eflags.EFLAG_ZF;
  58. break;
  59. //
  60. // Set if signed/not signed.
  61. //
  62. case 4:
  63. Condition = P->Eflags.EFLAG_SF;
  64. break;
  65. //
  66. // Set if parity/not parity.
  67. //
  68. case 5:
  69. Condition = P->Eflags.EFLAG_PF;
  70. break;
  71. //
  72. // Set if less/not less.
  73. //
  74. case 6:
  75. Condition = (P->Eflags.EFLAG_SF ^ P->Eflags.EFLAG_OF);
  76. break;
  77. //
  78. // Set if less or equal/not less or equal.
  79. //
  80. case 7:
  81. Condition = (P->Eflags.EFLAG_SF ^ P->Eflags.EFLAG_OF) | P->Eflags.EFLAG_ZF;
  82. break;
  83. }
  84. //
  85. // If the specified condition is met, then set the byte destination
  86. // value to one. Otherwise, set the byte destination value to zero.
  87. //
  88. XmStoreResult(P, (ULONG)(Condition ^ Complement));
  89. return;
  90. }