diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/nthals/x86new/miscops.c | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/ntos/nthals/x86new/miscops.c')
-rw-r--r-- | private/ntos/nthals/x86new/miscops.c | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/private/ntos/nthals/x86new/miscops.c b/private/ntos/nthals/x86new/miscops.c new file mode 100644 index 000000000..5cfd3cf2c --- /dev/null +++ b/private/ntos/nthals/x86new/miscops.c @@ -0,0 +1,179 @@ +/*++ + +Copyright (c) 1994 Microsoft Corporation + +Module Name: + + miscops.c + +Abstract: + + This module implements the code to emulate miscellaneous opcodes. + +Author: + + David N. Cutler (davec) 22-Sep-1994 + +Environment: + + Kernel mode only. + +Revision History: + +--*/ + +#include "nthal.h" +#include "emulate.h" + +VOID +XmBoundOp ( + PRXM_CONTEXT P + ) + +/*++ + +Routine Description: + + This function emulates a bound opcode. + +Arguments: + + P - Supplies a pointer to an emulator context structure. + +Return Value: + + None. + +--*/ + +{ + + union { + LONG Long; + SHORT Word; + } LowerBound; + + union { + LONG Long; + SHORT Word; + } UpperBound; + + ULONG Offset; + + // + // Get lower and upper bounds and check index against index value. + // + + Offset = P->SrcValue.Long; + XmSetSourceValue(P, XmGetOffsetAddress(P, Offset)); + LowerBound.Long = P->SrcValue.Long; + XmSetSourceValue(P, XmGetOffsetAddress(P, Offset + P->DataType + 1)); + UpperBound.Long = P->SrcValue.Long; + if (P->DataType == LONG_DATA) { + if (((LONG)(*P->DstLong) < LowerBound.Long) || + ((LONG)(*P->DstLong) > (UpperBound.Long + (LONG)(P->DataType + 1)))) { + longjmp(&P->JumpBuffer[0], XM_INDEX_OUT_OF_BOUNDS); + } + + } else { + if (((SHORT)(*P->DstWord) < LowerBound.Word) || + ((SHORT)(*P->DstWord) > (UpperBound.Word + (SHORT)(P->DataType + 1)))) { + longjmp(&P->JumpBuffer[0], XM_INDEX_OUT_OF_BOUNDS); + } + } + + return; +} + +VOID +XmBswapOp ( + PRXM_CONTEXT P + ) + +/*++ + +Routine Description: + + This function emulates a bswap opcode. + +Arguments: + + P - Supplies a pointer to an emulator context structure. + +Return Value: + + None. + +--*/ + +{ + + ULONG Result; + + // + // Swap bytes and set result value. + // + + Result = (P->SrcValue.Long << 24) | ((P->SrcValue.Long & 0xff00) << 8) | + (P->SrcValue.Long >> 24) | ((P->SrcValue.Long >> 8) & 0xff00); + + XmStoreResult(P, Result); + return; +} + +VOID +XmIllOp ( + PRXM_CONTEXT P + ) + +/*++ + +Routine Description: + + This function emulates an illegal opcode. + +Arguments: + + P - Supplies a pointer to an emulator context structure. + +Return Value: + + None. + +--*/ + +{ + + // + // Raise an illegal opcode exception. + // + + longjmp(&P->JumpBuffer[0], XM_ILLEGAL_INSTRUCTION_OPCODE); + return; +} + +VOID +XmNopOp ( + PRXM_CONTEXT P + ) + +/*++ + +Routine Description: + + This function emulates a nop opcode. + +Arguments: + + P - Supplies a pointer to an emulator context structure. + +Return Value: + + None. + +--*/ + +{ + + return; +} |