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.

179 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. movops.c
  5. Abstract:
  6. This module implements the code to emulate the move and exchange
  7. opcodes.
  8. Author:
  9. David N. Cutler (davec) 22-Sep-1994
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. --*/
  14. #include "nthal.h"
  15. #include "emulate.h"
  16. VOID
  17. XmCbwOp (
  18. IN PRXM_CONTEXT P
  19. )
  20. /*++
  21. Routine Description:
  22. This function emulates a cbw opcode.
  23. Arguments:
  24. P - Supplies a pointer to the emulation context structure.
  25. Return Value:
  26. None.
  27. --*/
  28. {
  29. //
  30. // Sign extend byte to word or word to double.
  31. //
  32. P->DstLong = (ULONG UNALIGNED *)(&P->Gpr[EAX].Exx);
  33. if (P->OpsizePrefixActive != FALSE) {
  34. P->DataType = LONG_DATA;
  35. XmStoreResult(P, (ULONG)((LONG)((SHORT)P->Gpr[AX].Xx)));
  36. } else {
  37. P->DataType = WORD_DATA;
  38. XmStoreResult(P, (ULONG)((USHORT)((SCHAR)P->Gpr[AL].Xl)));
  39. }
  40. return;
  41. }
  42. VOID
  43. XmCwdOp (
  44. IN PRXM_CONTEXT P
  45. )
  46. /*++
  47. Routine Description:
  48. This function emulates a cwd opcode.
  49. Arguments:
  50. P - Supplies a pointer to the emulation context structure.
  51. Return Value:
  52. None.
  53. --*/
  54. {
  55. //
  56. // Sign extend word to double or double to quad.
  57. //
  58. P->DstLong = (ULONG UNALIGNED *)(&P->Gpr[EDX].Exx);
  59. if (P->OpsizePrefixActive != FALSE) {
  60. P->DataType = LONG_DATA;
  61. XmStoreResult(P, (ULONG)((LONG)P->Gpr[EAX].Exx >> 31));
  62. } else {
  63. P->DataType = WORD_DATA;
  64. XmStoreResult(P, (ULONG)((USHORT)((SHORT)P->Gpr[AX].Xx >> 16)));
  65. }
  66. return;
  67. }
  68. VOID
  69. XmMovOp (
  70. IN PRXM_CONTEXT P
  71. )
  72. /*++
  73. Routine Description:
  74. This function emulates a move general opcode.
  75. Arguments:
  76. P - Supplies a pointer to the emulation context structure.
  77. Return Value:
  78. None.
  79. --*/
  80. {
  81. //
  82. // Move source to destination.
  83. //
  84. XmStoreResult(P, P->SrcValue.Long);
  85. return;
  86. }
  87. VOID
  88. XmXchgOp (
  89. IN PRXM_CONTEXT P
  90. )
  91. /*++
  92. Routine Description:
  93. This function emulates a xchg opcode.
  94. Arguments:
  95. P - Supplies a pointer to the emulation context structure.
  96. Return Value:
  97. None.
  98. --*/
  99. {
  100. //
  101. // Exchange source with destination.
  102. //
  103. if (P->DataType == BYTE_DATA) {
  104. *P->SrcByte = P->DstValue.Byte;
  105. } else if (P->DataType == LONG_DATA) {
  106. *P->SrcLong = P->DstValue.Long;
  107. } else {
  108. *P->SrcWord = P->DstValue.Word;
  109. }
  110. XmStoreResult(P, P->SrcValue.Long);
  111. return;
  112. }