Skip to content

Commit 69d2afb

Browse files
committed
Parser refactored
1 parent 9aff4d5 commit 69d2afb

File tree

5 files changed

+69
-269
lines changed

5 files changed

+69
-269
lines changed

BLSI.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int __stdcall BLSIInstructionEmulator(
88
UNREFERENCED_PARAMETER(instruction);
99
UNREFERENCED_PARAMETER(context);
1010

11-
unsigned int src;
11+
int src;
1212
if (instruction.src1 == MEM_32)
1313
{
1414
src = *(unsigned int*)getEffectiveVA(instruction.mem, context);
@@ -20,7 +20,7 @@ int __stdcall BLSIInstructionEmulator(
2020

2121
unsigned int operand_size = 32;
2222

23-
unsigned int dest = (-src) & src;
23+
int dest = -src & src;
2424

2525
// Set flags
2626
context->flags &= (~FLAG_ZF) & (~FLAG_SF) & (~FLAG_CF) & (~FLAG_OF);

Consts.h

+20-10
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,23 @@
4040

4141
// Instruction descriptors
4242

43-
#define INSTR_ANDN 0x00000000
44-
#define INSTR_BEXTR 0x10000000
45-
#define INSTR_BLSI 0x20000000
46-
#define INSTR_BLSMSK 0x30000000
47-
#define INSTR_BLSR 0x40000000
48-
#define INSTR_LZCNT 0x50000000
49-
#define INSTR_POPCNT 0x60000000
50-
#define INSTR_TZCNT 0x70000000
51-
#define INSTR_DEBUG 0xFFFFFFFE
52-
#define INSTR_UNKNOWN 0xFFFFFFFF
43+
#define INSTR_VVVV_USED 0x0001
44+
#define INSTR_16BIT 0x0002
45+
#define INSTR_SRC1_VVVV 0x0010
46+
#define INSTR_SRC1_RM 0x0020
47+
#define INSTR_SRC2_VVVV 0x0100
48+
#define INSTR_SRC2_RM 0x0200
49+
#define INSTR_DEST_VVVV 0x1000
50+
#define INSTR_DEST_REG 0x2000
51+
52+
53+
#define INSTR_ANDN (0x00000000 | INSTR_VVVV_USED | INSTR_SRC1_VVVV | INSTR_SRC2_RM | INSTR_DEST_REG)
54+
#define INSTR_BEXTR (0x10000000 | INSTR_VVVV_USED | INSTR_SRC1_RM | INSTR_SRC2_VVVV | INSTR_DEST_REG)
55+
#define INSTR_BLSI (0x20000000 | INSTR_VVVV_USED | INSTR_SRC1_RM | INSTR_DEST_VVVV)
56+
#define INSTR_BLSMSK (0x30000000 | INSTR_VVVV_USED | INSTR_SRC1_RM | INSTR_DEST_VVVV)
57+
#define INSTR_BLSR (0x40000000 | INSTR_VVVV_USED | INSTR_SRC1_RM | INSTR_DEST_VVVV)
58+
#define INSTR_LZCNT (0x50000000 | INSTR_16BIT | INSTR_SRC1_RM | INSTR_DEST_REG)
59+
#define INSTR_POPCNT (0x60000000 | INSTR_16BIT | INSTR_SRC1_RM | INSTR_DEST_REG)
60+
#define INSTR_TZCNT (0x70000000 | INSTR_16BIT | INSTR_SRC1_RM | INSTR_DEST_REG)
61+
#define INSTR_DEBUG (0xE0000000)
62+
#define INSTR_UNKNOWN (0xF0000000)

LZCNT.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ int __stdcall LZCNTInstructionEmulator(
2525
operand_size = 16;
2626
}
2727

28-
unsigned int temp = operand_size - 1;
29-
unsigned int dest = 0;
28+
int temp = operand_size - 1;
29+
int dest = 0;
3030

3131
while ((temp >= 0) && (src >> temp == 0))
3232
{
@@ -36,7 +36,7 @@ int __stdcall LZCNTInstructionEmulator(
3636

3737
// Set flags
3838
context->flags &= (~FLAG_ZF) & (~FLAG_CF);
39-
if (dest == operand_size)
39+
if (dest == (int)operand_size)
4040
{
4141
context->flags |= FLAG_CF;
4242
}

0 commit comments

Comments
 (0)