-
Notifications
You must be signed in to change notification settings - Fork 1
/
BLSI.c
45 lines (36 loc) · 767 Bytes
/
BLSI.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
41
42
43
44
45
#include "Driver.h"
#include "Parser.h"
int __stdcall BLSIInstructionEmulator(
ParsedInstruction instruction,
CALLER_CONTEXT* context)
{
UNREFERENCED_PARAMETER(instruction);
UNREFERENCED_PARAMETER(context);
int src;
if (instruction.src1 == MEM_32)
{
src = *(unsigned int*)getEffectiveVA(instruction.mem, context);
}
else
{
src = getRegValue(instruction.src1, context);
}
unsigned int operand_size = 32;
int dest = -src & src;
// Set flags
context->flags &= (~FLAG_ZF) & (~FLAG_SF) & (~FLAG_CF) & (~FLAG_OF);
if (src != 0)
{
context->flags |= FLAG_CF;
}
if (dest == 0)
{
context->flags |= FLAG_ZF;
}
if (dest >> (operand_size - 1))
{
context->flags |= FLAG_SF;
}
setRegValue(instruction.dest, dest, context);
return TRUE;
}