summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/x86new/stackops.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/nthals/x86new/stackops.c
downloadNT4.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/stackops.c')
-rw-r--r--private/ntos/nthals/x86new/stackops.c195
1 files changed, 195 insertions, 0 deletions
diff --git a/private/ntos/nthals/x86new/stackops.c b/private/ntos/nthals/x86new/stackops.c
new file mode 100644
index 000000000..33ae35b77
--- /dev/null
+++ b/private/ntos/nthals/x86new/stackops.c
@@ -0,0 +1,195 @@
+/*++
+
+Copyright (c) 1994 Microsoft Corporation
+
+Module Name:
+
+ stackops.c
+
+Abstract:
+
+ This module implements the code to emulate the push, pop, pushf, popf,
+ pusha, popa, pushSeg, and popSeg.
+
+Author:
+
+ David N. Cutler (davec) 6-Sep-1994
+
+Environment:
+
+ Kernel mode only.
+
+Revision History:
+
+--*/
+
+#include "nthal.h"
+#include "emulate.h"
+
+VOID
+XmPushOp (
+ IN PRXM_CONTEXT P
+ )
+
+/*++
+
+Routine Description:
+
+ This function emulates a push opcode.
+
+Arguments:
+
+ P - Supplies a pointer to the emulation context structure.
+
+Return Value:
+
+ None.
+
+--*/
+
+{
+
+ //
+ // Push source value onto stack.
+ //
+
+ XmPushStack(P, P->SrcValue.Long);
+ return;
+}
+
+VOID
+XmPopOp (
+ IN PRXM_CONTEXT P
+ )
+
+/*++
+
+Routine Description:
+
+ This function emulates a pop opcode.
+
+Arguments:
+
+ P - Supplies a pointer to the emulation context structure.
+
+Return Value:
+
+ None.
+
+--*/
+
+{
+
+ //
+ // Pop the stack and store the result value.
+ //
+
+ XmStoreResult(P, XmPopStack(P));
+ return;
+}
+
+VOID
+XmPushaOp (
+ IN PRXM_CONTEXT P
+ )
+
+/*++
+
+Routine Description:
+
+ This function emulates a pusha opcode.
+
+Arguments:
+
+ P - Supplies a pointer to the emulation context structure.
+
+Return Value:
+
+ None.
+
+--*/
+
+{
+
+ ULONG Index;
+ ULONG Temp;
+
+ //
+ // Push all registers onto the stack.
+ //
+
+ if (P->OpsizePrefixActive != FALSE) {
+ P->DataType = LONG_DATA;
+
+ } else {
+ P->DataType = WORD_DATA;
+ }
+
+ Index = EAX;
+ Temp = P->Gpr[ESP].Exx;
+ do {
+ if (Index == ESP) {
+ XmSetSourceValue(P, (PVOID)&Temp);
+
+ } else {
+ XmSetSourceValue(P, (PVOID)(&P->Gpr[Index].Exx));
+ }
+
+ XmPushOp(P);
+ Index += 1;
+ } while (Index <= EDI);
+ return;
+}
+
+VOID
+XmPopaOp (
+ IN PRXM_CONTEXT P
+ )
+
+/*++
+
+Routine Description:
+
+ This function emulates a popa opcode.
+
+Arguments:
+
+ P - Supplies a pointer to the emulation context structure.
+
+Return Value:
+
+ None.
+
+--*/
+
+{
+
+ ULONG Index;
+ ULONG Temp;
+
+ //
+ // Pop all register from the stack, but skip over ESP.
+ //
+
+ if (P->OpsizePrefixActive != FALSE) {
+ P->DataType = LONG_DATA;
+
+ } else {
+ P->DataType = WORD_DATA;
+ }
+
+ Index = EDI + 1;
+ Temp = P->Gpr[ESP].Exx;
+ do {
+ Index -= 1;
+ if (Index == ESP) {
+ XmSetDestinationValue(P, (PVOID)&Temp);
+
+ } else {
+ XmSetDestinationValue(P, (PVOID)(&P->Gpr[Index].Exx));
+ }
+
+ XmPopOp(P);
+ } while (Index > EAX);
+ return;
+}