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.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. miscops.c
  5. Abstract:
  6. This module implements the code to emulate miscellaneous 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. XmBoundOp (
  17. PRXM_CONTEXT P
  18. )
  19. /*++
  20. Routine Description:
  21. This function emulates a bound opcode.
  22. Arguments:
  23. P - Supplies a pointer to an emulator context structure.
  24. Return Value:
  25. None.
  26. --*/
  27. {
  28. union {
  29. LONG Long;
  30. SHORT Word;
  31. } LowerBound;
  32. union {
  33. LONG Long;
  34. SHORT Word;
  35. } UpperBound;
  36. ULONG Offset;
  37. //
  38. // Get lower and upper bounds and check index against index value.
  39. //
  40. Offset = P->SrcValue.Long;
  41. XmSetSourceValue(P, XmGetOffsetAddress(P, Offset));
  42. LowerBound.Long = P->SrcValue.Long;
  43. XmSetSourceValue(P, XmGetOffsetAddress(P, Offset + P->DataType + 1));
  44. UpperBound.Long = P->SrcValue.Long;
  45. if (P->DataType == LONG_DATA) {
  46. if (((LONG)(*P->DstLong) < LowerBound.Long) ||
  47. ((LONG)(*P->DstLong) > (UpperBound.Long + (LONG)(P->DataType + 1)))) {
  48. longjmp(&P->JumpBuffer[0], XM_INDEX_OUT_OF_BOUNDS);
  49. }
  50. } else {
  51. if (((SHORT)(*P->DstWord) < LowerBound.Word) ||
  52. ((SHORT)(*P->DstWord) > (UpperBound.Word + (SHORT)(P->DataType + 1)))) {
  53. longjmp(&P->JumpBuffer[0], XM_INDEX_OUT_OF_BOUNDS);
  54. }
  55. }
  56. return;
  57. }
  58. VOID
  59. XmBswapOp (
  60. PRXM_CONTEXT P
  61. )
  62. /*++
  63. Routine Description:
  64. This function emulates a bswap opcode.
  65. Arguments:
  66. P - Supplies a pointer to an emulator context structure.
  67. Return Value:
  68. None.
  69. --*/
  70. {
  71. ULONG Result;
  72. //
  73. // Swap bytes and set result value.
  74. //
  75. Result = (P->SrcValue.Long << 24) | ((P->SrcValue.Long & 0xff00) << 8) |
  76. (P->SrcValue.Long >> 24) | ((P->SrcValue.Long >> 8) & 0xff00);
  77. XmStoreResult(P, Result);
  78. return;
  79. }
  80. VOID
  81. XmIllOp (
  82. PRXM_CONTEXT P
  83. )
  84. /*++
  85. Routine Description:
  86. This function emulates an illegal opcode.
  87. Arguments:
  88. P - Supplies a pointer to an emulator context structure.
  89. Return Value:
  90. None.
  91. --*/
  92. {
  93. //
  94. // Raise an illegal opcode exception.
  95. //
  96. longjmp(&P->JumpBuffer[0], XM_ILLEGAL_INSTRUCTION_OPCODE);
  97. return;
  98. }
  99. VOID
  100. XmNopOp (
  101. PRXM_CONTEXT P
  102. )
  103. /*++
  104. Routine Description:
  105. This function emulates a nop opcode.
  106. Arguments:
  107. P - Supplies a pointer to an emulator context structure.
  108. Return Value:
  109. None.
  110. --*/
  111. {
  112. return;
  113. }