Source code of Windows XP (NT5)
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.

310 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. condops.c
  5. Abstract:
  6. This module implements the code to emulate condition code opcodes.
  7. Author:
  8. David N. Cutler (davec) 22-Sep-1994
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "nthal.h"
  14. #include "emulate.h"
  15. VOID
  16. XmClcOp (
  17. PRXM_CONTEXT P
  18. )
  19. /*++
  20. Routine Description:
  21. This function emulates a clc opcode.
  22. Arguments:
  23. P - Supplies a pointer to an emulator context structure.
  24. Return Value:
  25. None.
  26. --*/
  27. {
  28. //
  29. // Clear carry flag.
  30. //
  31. P->Eflags.EFLAG_CF = 0;
  32. return;
  33. }
  34. VOID
  35. XmCldOp (
  36. PRXM_CONTEXT P
  37. )
  38. /*++
  39. Routine Description:
  40. This function emulates a cld opcode.
  41. Arguments:
  42. P - Supplies a pointer to an emulator context structure.
  43. Return Value:
  44. None.
  45. --*/
  46. {
  47. //
  48. // Clear direction flag.
  49. //
  50. P->Eflags.EFLAG_DF = 0;
  51. return;
  52. }
  53. VOID
  54. XmCliOp (
  55. PRXM_CONTEXT P
  56. )
  57. /*++
  58. Routine Description:
  59. This function emulates a cli opcode.
  60. Arguments:
  61. P - Supplies a pointer to an emulator context structure.
  62. Return Value:
  63. None.
  64. --*/
  65. {
  66. //
  67. // Clear interrupt flag.
  68. //
  69. P->Eflags.EFLAG_IF = 0;
  70. return;
  71. }
  72. VOID
  73. XmCmcOp (
  74. PRXM_CONTEXT P
  75. )
  76. /*++
  77. Routine Description:
  78. This function emulates a cmc opcode.
  79. Arguments:
  80. P - Supplies a pointer to an emulator context structure.
  81. Return Value:
  82. None.
  83. --*/
  84. {
  85. //
  86. // Complement carry flag.
  87. //
  88. P->Eflags.EFLAG_CF ^= 1;
  89. return;
  90. }
  91. VOID
  92. XmStcOp (
  93. PRXM_CONTEXT P
  94. )
  95. /*++
  96. Routine Description:
  97. This function emulates a stc opcode.
  98. Arguments:
  99. P - Supplies a pointer to an emulator context structure.
  100. Return Value:
  101. None.
  102. --*/
  103. {
  104. //
  105. // Set carry flag.
  106. //
  107. P->Eflags.EFLAG_CF = 1;
  108. return;
  109. }
  110. VOID
  111. XmStdOp (
  112. PRXM_CONTEXT P
  113. )
  114. /*++
  115. Routine Description:
  116. This function emulates a std opcode.
  117. Arguments:
  118. P - Supplies a pointer to an emulator context structure.
  119. Return Value:
  120. None.
  121. --*/
  122. {
  123. //
  124. // Set direction flag.
  125. //
  126. P->Eflags.EFLAG_DF = 1;
  127. return;
  128. }
  129. VOID
  130. XmStiOp (
  131. PRXM_CONTEXT P
  132. )
  133. /*++
  134. Routine Description:
  135. This function emulates a sti opcode.
  136. Arguments:
  137. P - Supplies a pointer to an emulator context structure.
  138. Return Value:
  139. None.
  140. --*/
  141. {
  142. //
  143. // Set interrupt flag.
  144. //
  145. P->Eflags.EFLAG_IF = 1;
  146. return;
  147. }
  148. VOID
  149. XmLahfOp (
  150. PRXM_CONTEXT P
  151. )
  152. /*++
  153. Routine Description:
  154. This function emulates a lahf opcode.
  155. Arguments:
  156. P - Supplies a pointer to an emulator context structure.
  157. Return Value:
  158. None.
  159. --*/
  160. {
  161. //
  162. // Load flags into AH.
  163. //
  164. P->DataType = BYTE_DATA;
  165. P->DstByte = &P->Gpr[AX].Xh;
  166. XmStoreResult(P, (ULONG)P->AhFlags);
  167. return;
  168. }
  169. VOID
  170. XmSahfOp (
  171. PRXM_CONTEXT P
  172. )
  173. /*++
  174. Routine Description:
  175. This function emulates a sahf opcode.
  176. Arguments:
  177. P - Supplies a pointer to an emulator context structure.
  178. Return Value:
  179. None.
  180. --*/
  181. {
  182. //
  183. // Store CF, PF, AF, ZF, SF of AH in flags.
  184. //
  185. P->AhFlags = P->Gpr[AX].Xh;
  186. P->Eflags.EFLAG_MBO = 1;
  187. P->Eflags.EFLAG_SBZ0 = 0;
  188. P->Eflags.EFLAG_SBZ1 = 0;
  189. return;
  190. }