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.

195 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. stackops.c
  5. Abstract:
  6. This module implements the code to emulate the push, pop, pushf, popf,
  7. pusha, popa, pushSeg, and popSeg.
  8. Author:
  9. David N. Cutler (davec) 6-Sep-1994
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. --*/
  14. #include "nthal.h"
  15. #include "emulate.h"
  16. VOID
  17. XmPushOp (
  18. IN PRXM_CONTEXT P
  19. )
  20. /*++
  21. Routine Description:
  22. This function emulates a push opcode.
  23. Arguments:
  24. P - Supplies a pointer to the emulation context structure.
  25. Return Value:
  26. None.
  27. --*/
  28. {
  29. //
  30. // Push source value onto stack.
  31. //
  32. XmPushStack(P, P->SrcValue.Long);
  33. return;
  34. }
  35. VOID
  36. XmPopOp (
  37. IN PRXM_CONTEXT P
  38. )
  39. /*++
  40. Routine Description:
  41. This function emulates a pop opcode.
  42. Arguments:
  43. P - Supplies a pointer to the emulation context structure.
  44. Return Value:
  45. None.
  46. --*/
  47. {
  48. //
  49. // Pop the stack and store the result value.
  50. //
  51. XmStoreResult(P, XmPopStack(P));
  52. return;
  53. }
  54. VOID
  55. XmPushaOp (
  56. IN PRXM_CONTEXT P
  57. )
  58. /*++
  59. Routine Description:
  60. This function emulates a pusha opcode.
  61. Arguments:
  62. P - Supplies a pointer to the emulation context structure.
  63. Return Value:
  64. None.
  65. --*/
  66. {
  67. ULONG Index;
  68. ULONG Temp;
  69. //
  70. // Push all registers onto the stack.
  71. //
  72. if (P->OpsizePrefixActive != FALSE) {
  73. P->DataType = LONG_DATA;
  74. } else {
  75. P->DataType = WORD_DATA;
  76. }
  77. Index = EAX;
  78. Temp = P->Gpr[ESP].Exx;
  79. do {
  80. if (Index == ESP) {
  81. XmSetSourceValue(P, (PVOID)&Temp);
  82. } else {
  83. XmSetSourceValue(P, (PVOID)(&P->Gpr[Index].Exx));
  84. }
  85. XmPushOp(P);
  86. Index += 1;
  87. } while (Index <= EDI);
  88. return;
  89. }
  90. VOID
  91. XmPopaOp (
  92. IN PRXM_CONTEXT P
  93. )
  94. /*++
  95. Routine Description:
  96. This function emulates a popa opcode.
  97. Arguments:
  98. P - Supplies a pointer to the emulation context structure.
  99. Return Value:
  100. None.
  101. --*/
  102. {
  103. ULONG Index;
  104. ULONG Temp;
  105. //
  106. // Pop all register from the stack, but skip over ESP.
  107. //
  108. if (P->OpsizePrefixActive != FALSE) {
  109. P->DataType = LONG_DATA;
  110. } else {
  111. P->DataType = WORD_DATA;
  112. }
  113. Index = EDI + 1;
  114. Temp = P->Gpr[ESP].Exx;
  115. do {
  116. Index -= 1;
  117. if (Index == ESP) {
  118. XmSetDestinationValue(P, (PVOID)&Temp);
  119. } else {
  120. XmSetDestinationValue(P, (PVOID)(&P->Gpr[Index].Exx));
  121. }
  122. XmPopOp(P);
  123. } while (Index > EAX);
  124. return;
  125. }