-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathANDN.c
40 lines (33 loc) · 776 Bytes
/
ANDN.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "Driver.h"
#include "Parser.h"
int __stdcall ANDNInstructionEmulator(
ParsedInstruction instruction,
CALLER_CONTEXT* context)
{
UNREFERENCED_PARAMETER(instruction);
UNREFERENCED_PARAMETER(context);
unsigned int src1 = getRegValue(instruction.src1, context);
unsigned int src2;
if (instruction.src2 == MEM_32)
{
src2 = *(unsigned int*)getEffectiveVA(instruction.mem, context);
}
else
{
src2 = getRegValue(instruction.src2, context);
}
unsigned int dest = (~src1) & src2;
unsigned int SF = dest >> 31;
// Set flags
context->flags &= (~FLAG_SF) & (~FLAG_ZF) & (~FLAG_OF) & (~FLAG_CF);
if (SF)
{
context->flags |= FLAG_SF;
}
if (dest == 0)
{
context->flags |= FLAG_ZF;
}
setRegValue(instruction.dest, dest, context);
return TRUE;
}