Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,879 changes: 1,674 additions & 205 deletions arch/X86/X86Mapping.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/unit/x86_apx_cmov.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static void encode_evex(uint8_t code[6], unsigned int cc, bool nd, bool nf,
code[5] = 0xc0 | ((reg & 7) << 3) | (rm & 7);
}

static bool has_register(const cs_regs registers, uint8_t count, x86_reg reg)
static bool has_register(const uint16_t *registers, uint8_t count, x86_reg reg)
{
uint8_t i;

Expand Down
113 changes: 84 additions & 29 deletions tests/unit/x86_apx_evex_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,88 @@ static bool one(csh h,const uint8_t*b,size_t n,unsigned id,const char*m,const ch
cs_free(i,ok||i?1:0);return ok;
}

int main(void)
{
const uint8_t ml16[]={0x62,0xec,0x7d,0x08,0x60,0xd3};
const uint8_t ms32[]={0x62,0xec,0x7c,0x08,0x61,0xda};
const uint8_t mlm[]={0x64,0x62,0x0c,0x7c,0x08,0x60,0x54,0xb5,0x20};
const uint8_t cb[]={0x62,0xec,0xfc,0x08,0xf0,0xd3};
const uint8_t cw[]={0x62,0xec,0x7d,0x08,0xf1,0xd3};
const uint8_t cq[]={0x64,0x62,0x0c,0xfc,0x08,0xf1,0x54,0xb5,0x20};
uint8_t bad[]={0x62,0xec,0x7c,0x08,0x60,0xd3};csh h;cs_insn*i=NULL;bool ok=true;
if(cs_open(CS_ARCH_X86,CS_MODE_64,&h))return 1;cs_option(h,CS_OPT_DETAIL,CS_OPT_ON);
ok&=one(h,ml16,sizeof(ml16),X86_INS_MOVBE,"movbe","r18w, r19w");
ok&=one(h,ms32,sizeof(ms32),X86_INS_MOVBE,"movbe","r18d, r19d");
if(cs_disasm(h,ms32,sizeof(ms32),0,1,&i)!=1)ok=false;else{const cs_x86*x=&i->detail->x86;ok&=x->operands[0].reg==X86_REG_R18D&&x->operands[0].access==CS_AC_WRITE&&x->operands[1].reg==X86_REG_R19D&&x->operands[1].access==CS_AC_READ;cs_free(i,1);i=NULL;}
ok&=one(h,mlm,sizeof(mlm),X86_INS_MOVBE,"movbe","r26d, dword ptr fs:[r29 + r14*4 + 0x20]");
ok&=one(h,cb,sizeof(cb),X86_INS_CRC32,"crc32","r18, r19b");
ok&=one(h,cw,sizeof(cw),X86_INS_CRC32,"crc32","r18d, r19w");
ok&=one(h,cq,sizeof(cq),X86_INS_CRC32,"crc32","r26, qword ptr fs:[r29 + r14*4 + 0x20]");
if(cs_disasm(h,cq,sizeof(cq),0,1,&i)!=1)ok=false;else{const cs_x86*x=&i->detail->x86;ok&=x->op_count==2&&x->operands[0].reg==X86_REG_R26&&x->operands[0].access==CS_AC_READ_WRITE&&x->operands[1].type==X86_OP_MEM&&x->operands[1].access==CS_AC_READ&&x->operands[1].mem.segment==X86_REG_FS&&x->operands[1].mem.base==X86_REG_R29&&x->operands[1].mem.index==X86_REG_R14;cs_free(i,1);i=NULL;}
/* W selects 64-bit operands over 66, as XED decodes them. */
{const uint8_t mw[]={0x62,0xec,0xfd,0x08,0x60,0xd3};const uint8_t cw66[]={0x62,0xec,0xfd,0x08,0xf1,0xd3};
ok&=one(h,mw,sizeof(mw),X86_INS_MOVBE,"movbe","r18, r19");
ok&=one(h,cw66,sizeof(cw66),X86_INS_CRC32,"crc32","r18, r19");}
cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_ATT);
ok&=one(h,cq,sizeof(cq),X86_INS_CRC32,"crc32q","%fs:0x20(%r29,%r14,4), %r26");
cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_INTEL);
for(unsigned k=0;k<4;k++){bad[3]=(uint8_t[]){0x00,0x0c,0x18,0x28}[k];if(cs_disasm(h,bad,sizeof(bad),0,1,&i)){ok=false;cs_free(i,1);i=NULL;}}
bad[2]=0x74;bad[3]=8;if(cs_disasm(h,bad,sizeof(bad),0,1,&i)){ok=false;cs_free(i,1);i=NULL;}
bad[2]=0x7d;bad[3]=8;bad[4]=0xf0;if(cs_disasm(h,bad,sizeof(bad),0,1,&i)){ok=false;cs_free(i,1);}
cs_close(&h);if(!ok)fprintf(stderr,"APX conversion failure\n");return ok?0:1;
int main(void) {
const uint8_t ml16[] = {0x62, 0xec, 0x7d, 0x08, 0x60, 0xd3};
const uint8_t ms32[] = {0x62, 0xec, 0x7c, 0x08, 0x61, 0xda};
const uint8_t mlm[] = {0x64, 0x62, 0x0c, 0x7c, 0x08, 0x60, 0x54, 0xb5, 0x20};
const uint8_t cb[] = {0x62, 0xec, 0xfc, 0x08, 0xf0, 0xd3};
const uint8_t cw[] = {0x62, 0xec, 0x7d, 0x08, 0xf1, 0xd3};
const uint8_t cq[] = {0x64, 0x62, 0x0c, 0xfc, 0x08, 0xf1, 0x54, 0xb5, 0x20};
uint8_t bad[] = {0x62, 0xec, 0x7c, 0x08, 0x60, 0xd3};
csh h;
cs_insn *i = NULL;
bool ok = true;
if (cs_open(CS_ARCH_X86, CS_MODE_64, &h))
return 1;
cs_option(h, CS_OPT_DETAIL, CS_OPT_ON);
ok &= one(h, ml16, sizeof(ml16), X86_INS_MOVBE, "movbe", "r18w, r19w");
ok &= one(h, ms32, sizeof(ms32), X86_INS_MOVBE, "movbe", "r18d, r19d");
if (cs_disasm(h, ms32, sizeof(ms32), 0, 1, &i) != 1)
ok = false;
else {
const cs_x86 *x = &i->detail->x86;
ok &= x->operands[0].reg == X86_REG_R18D &&
x->operands[0].access == CS_AC_WRITE &&
x->operands[1].reg == X86_REG_R19D &&
x->operands[1].access == CS_AC_READ;
cs_free(i, 1);
i = NULL;
}
ok &= one(h, mlm, sizeof(mlm), X86_INS_MOVBE, "movbe",
"r26d, dword ptr fs:[r29 + r14*4 + 0x20]");
ok &= one(h, cb, sizeof(cb), X86_INS_CRC32, "crc32", "r18, r19b");
ok &= one(h, cw, sizeof(cw), X86_INS_CRC32, "crc32", "r18d, r19w");
ok &= one(h, cq, sizeof(cq), X86_INS_CRC32, "crc32",
"r26, qword ptr fs:[r29 + r14*4 + 0x20]");
if (cs_disasm(h, cq, sizeof(cq), 0, 1, &i) != 1)
ok = false;
else {
const cs_x86 *x = &i->detail->x86;
ok &= x->op_count == 2 && x->operands[0].reg == X86_REG_R26 &&
x->operands[0].access == CS_AC_READ_WRITE &&
x->operands[1].type == X86_OP_MEM &&
x->operands[1].access == CS_AC_READ &&
x->operands[1].mem.segment == X86_REG_FS &&
x->operands[1].mem.base == X86_REG_R29 &&
x->operands[1].mem.index == X86_REG_R14;
cs_free(i, 1);
i = NULL;
}
/* W selects 64-bit operands over 66, as XED decodes them. */
{
const uint8_t mw[] = {0x62, 0xec, 0xfd, 0x08, 0x60, 0xd3};
const uint8_t cw66[] = {0x62, 0xec, 0xfd, 0x08, 0xf1, 0xd3};
ok &= one(h, mw, sizeof(mw), X86_INS_MOVBE, "movbe", "r18, r19");
ok &= one(h, cw66, sizeof(cw66), X86_INS_CRC32, "crc32", "r18, r19");
}
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT);
ok &= one(h, cq, sizeof(cq), X86_INS_CRC32, "crc32q",
"%fs:0x20(%r29,%r14,4), %r26");
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
for (unsigned k = 0; k < 4; k++) {
bad[3] = (uint8_t[]){0x00, 0x0c, 0x18, 0x28}[k];
if (cs_disasm(h, bad, sizeof(bad), 0, 1, &i)) {
ok = false;
cs_free(i, 1);
i = NULL;
}
}
bad[2] = 0x74;
bad[3] = 8;
if (cs_disasm(h, bad, sizeof(bad), 0, 1, &i)) {
ok = false;
cs_free(i, 1);
i = NULL;
}
bad[2] = 0x7d;
bad[3] = 8;
bad[4] = 0xf0;
if (cs_disasm(h, bad, sizeof(bad), 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
cs_close(&h);
if (!ok)
fprintf(stderr, "APX conversion failure\n");
return ok ? 0 : 1;
}
2 changes: 1 addition & 1 deletion tests/unit/x86_apx_evex_duplicate_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static bool decodes(csh handle, const uint8_t *code, size_t size,
{
cs_insn *instruction = NULL;
size_t count = cs_disasm(handle, code, size, 0, 1, &instruction);
char actual[160] = "";
char actual[sizeof(instruction->mnemonic) + sizeof(instruction->op_str)] = "";
bool ok;

if (count == 1)
Expand Down
69 changes: 54 additions & 15 deletions tests/unit/x86_apx_evex_invalidate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,58 @@ static bool ck(csh h,const uint8_t*b,size_t n,unsigned id,const char*mn,const ch
cs_free(i,1);return ok;
}

int main(void)
{
csh h;cs_insn*i=NULL;bool ok=true;uint8_t b[]={0x62,0xec,0x7e,8,0xf0,0x11};
const unsigned ids[]={X86_INS_INVEPT,X86_INS_INVVPID,X86_INS_INVPCID};
const char*mn[]={"invept","invvpid","invpcid"};
if(cs_open(CS_ARCH_X86,CS_MODE_64,&h))return 1;cs_option(h,CS_OPT_DETAIL,CS_OPT_ON);
for(unsigned k=0;k<3;k++){b[4]=(uint8_t)(0xf0+k);ok&=ck(h,b,6,ids[k],mn[k],
k==0?"r18, xmmword ptr [r17]":k==1?"r18, xmmword ptr [r17]":"r18, xmmword ptr [r17]");}
b[2]=0xfe;b[4]=0xf0;ok&=ck(h,b,6,X86_INS_INVEPT,"invept","r18, xmmword ptr [r17]");
{const uint8_t a[]={0x64,0x67,0x62,0xec,0x7a,8,0xf2,0x11};
ok&=ck(h,a,sizeof(a),X86_INS_INVPCID,"invpcid","r18, xmmword ptr fs:[r17d]");
cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_ATT);ok&=ck(h,a,sizeof(a),X86_INS_INVPCID,
"invpcid","%fs:(%r17d), %r18");cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_INTEL);}
{uint8_t x[]={0x62,0xec,0x7e,8,0xf0,0xd1};if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[5]=0x11;x[3]=9;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[3]=8;x[2]=0x7f;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[2]=0x76;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}}
cs_close(&h);return ok?0:1;
int main(void) {
csh h;
cs_insn *i = NULL;
bool ok = true;
uint8_t b[] = {0x62, 0xec, 0x7e, 8, 0xf0, 0x11};
const unsigned ids[] = {X86_INS_INVEPT, X86_INS_INVVPID, X86_INS_INVPCID};
const char *mn[] = {"invept", "invvpid", "invpcid"};
if (cs_open(CS_ARCH_X86, CS_MODE_64, &h))
return 1;
cs_option(h, CS_OPT_DETAIL, CS_OPT_ON);
for (unsigned k = 0; k < 3; k++) {
b[4] = (uint8_t)(0xf0 + k);
ok &= ck(h, b, 6, ids[k], mn[k],
k == 0 ? "r18, xmmword ptr [r17]"
: k == 1 ? "r18, xmmword ptr [r17]"
: "r18, xmmword ptr [r17]");
}
b[2] = 0xfe;
b[4] = 0xf0;
ok &= ck(h, b, 6, X86_INS_INVEPT, "invept", "r18, xmmword ptr [r17]");
{
const uint8_t a[] = {0x64, 0x67, 0x62, 0xec, 0x7a, 8, 0xf2, 0x11};
ok &= ck(h, a, sizeof(a), X86_INS_INVPCID, "invpcid",
"r18, xmmword ptr fs:[r17d]");
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT);
ok &= ck(h, a, sizeof(a), X86_INS_INVPCID, "invpcid", "%fs:(%r17d), %r18");
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
}
{
uint8_t x[] = {0x62, 0xec, 0x7e, 8, 0xf0, 0xd1};
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[5] = 0x11;
x[3] = 9;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[3] = 8;
x[2] = 0x7f;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[2] = 0x76;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
}
cs_close(&h);
return ok ? 0 : 1;
}
148 changes: 110 additions & 38 deletions tests/unit/x86_apx_evex_kmov.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,114 @@ static bool ck(csh h,const uint8_t*b,size_t n,unsigned id,const char*mn,
cs_free(i,1);return ok;
}

int main(void)
{
csh h;cs_insn*i=NULL;bool ok=true;
const uint8_t kk[][6]={{0x62,0xf1,0x7d,8,0x90,0xd9},{0x62,0xf1,0x7c,8,0x90,0xd9},
{0x62,0xf1,0xfd,8,0x90,0xd9},{0x62,0xf1,0xfc,8,0x90,0xd9}};
const unsigned ids[]={X86_INS_KMOVB,X86_INS_KMOVW,X86_INS_KMOVD,X86_INS_KMOVQ};
const char*mn[]={"kmovb","kmovw","kmovd","kmovq"};uint8_t sz[]={1,2,4,8};
if(cs_open(CS_ARCH_X86,CS_MODE_64,&h))return 1;cs_option(h,CS_OPT_DETAIL,CS_OPT_ON);
for(unsigned k=0;k<4;k++)ok&=ck(h,kk[k],6,ids[k],mn[k],"k3, k1",sz[k],sz[k]);
{const uint8_t legacy[]={0xc5,0xf9,0x90,0xd9};
ok&=ck(h,legacy,4,X86_INS_KMOVB,"kmovb","k3, k1",1,1);}
{const uint8_t b[]={0x62,0xf9,0x7d,8,0x92,0xd9};ok&=ck(h,b,6,X86_INS_KMOVB,"kmovb","k3, r17d",1,4);}
{const uint8_t b[]={0x62,0xe1,0x7d,8,0x93,0xcb};ok&=ck(h,b,6,X86_INS_KMOVB,"kmovb","r17d, k3",4,1);}
{const uint8_t b[]={0x62,0xf9,0x7f,8,0x92,0xd9};ok&=ck(h,b,6,X86_INS_KMOVD,"kmovd","k3, r17d",4,4);}
{const uint8_t b[]={0x62,0xf9,0x7c,8,0x92,0xd9};ok&=ck(h,b,6,X86_INS_KMOVW,"kmovw","k3, r17d",2,4);}
{const uint8_t b[]={0x62,0xe1,0x7c,8,0x93,0xcb};ok&=ck(h,b,6,X86_INS_KMOVW,"kmovw","r17d, k3",4,2);}
{const uint8_t b[]={0x62,0xf9,0xff,8,0x92,0xd9};ok&=ck(h,b,6,X86_INS_KMOVQ,"kmovq","k3, r17",8,8);}
{uint8_t b[]={0x64,0x62,0xf9,0,8,0x90,0x11};
const uint8_t p[]={0x7d,0x7c,0xfd,0xfc};
const char*ld[]={"k2, byte ptr fs:[r17]","k2, word ptr fs:[r17]",
"k2, dword ptr fs:[r17]","k2, qword ptr fs:[r17]"};
const char*st[]={"byte ptr fs:[r17], k3","word ptr fs:[r17], k3",
"dword ptr fs:[r17], k3","qword ptr fs:[r17], k3"};
for(unsigned k=0;k<4;k++){b[3]=p[k];b[5]=0x90;b[6]=0x11;
ok&=ck(h,b,7,ids[k],mn[k],ld[k],sz[k],sz[k]);
b[5]=0x91;b[6]=0x19;ok&=ck(h,b,7,ids[k],mn[k],st[k],sz[k],sz[k]);}}
{const uint8_t b[]={0x64,0x62,0x99,0xf9,8,0x90,0x54,0xa5,0x20};
ok&=ck(h,b,sizeof(b),X86_INS_KMOVD,"kmovd",
"k2, dword ptr fs:[r29 + r28*4 + 0x20]",4,4);}
{const uint8_t b[]={0x64,0x62,0x99,0xf9,8,0x91,0x5c,0xa5,0x20};
ok&=ck(h,b,sizeof(b),X86_INS_KMOVD,"kmovd",
"dword ptr fs:[r29 + r28*4 + 0x20], k3",4,4);}
{const uint8_t b[]={0x67,0x64,0x62,0x99,0xf9,8,0x90,0x54,0xa5,0x20};
ok&=ck(h,b,sizeof(b),X86_INS_KMOVD,"kmovd",
"k2, dword ptr fs:[r29d + r28d*4 + 0x20]",4,4);}
{const uint8_t b[]={0x62,0xf9,0xff,8,0x92,0xd9};cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_ATT);ok&=ck(h,b,6,X86_INS_KMOVQ,"kmovq","%r17, %k3",8,8);cs_option(h,CS_OPT_SYNTAX,CS_OPT_SYNTAX_INTEL);}
{uint8_t x[]={0x62,0xf9,0x7d,8,0x92,0x19};if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[3]=9;x[5]=0xd9;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[3]=8;x[2]=0x79;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}x[2]=0x75;if(cs_disasm(h,x,6,0,1,&i)){ok=false;cs_free(i,1);}}
cs_close(&h);return ok?0:1;
int main(void) {
csh h;
cs_insn *i = NULL;
bool ok = true;
const uint8_t kk[][6] = {{0x62, 0xf1, 0x7d, 8, 0x90, 0xd9},
{0x62, 0xf1, 0x7c, 8, 0x90, 0xd9},
{0x62, 0xf1, 0xfd, 8, 0x90, 0xd9},
{0x62, 0xf1, 0xfc, 8, 0x90, 0xd9}};
const unsigned ids[] = {X86_INS_KMOVB, X86_INS_KMOVW, X86_INS_KMOVD,
X86_INS_KMOVQ};
const char *mn[] = {"kmovb", "kmovw", "kmovd", "kmovq"};
uint8_t sz[] = {1, 2, 4, 8};
if (cs_open(CS_ARCH_X86, CS_MODE_64, &h))
return 1;
cs_option(h, CS_OPT_DETAIL, CS_OPT_ON);
for (unsigned k = 0; k < 4; k++)
ok &= ck(h, kk[k], 6, ids[k], mn[k], "k3, k1", sz[k], sz[k]);
{
const uint8_t legacy[] = {0xc5, 0xf9, 0x90, 0xd9};
ok &= ck(h, legacy, 4, X86_INS_KMOVB, "kmovb", "k3, k1", 1, 1);
}
{
const uint8_t b[] = {0x62, 0xf9, 0x7d, 8, 0x92, 0xd9};
ok &= ck(h, b, 6, X86_INS_KMOVB, "kmovb", "k3, r17d", 1, 4);
}
{
const uint8_t b[] = {0x62, 0xe1, 0x7d, 8, 0x93, 0xcb};
ok &= ck(h, b, 6, X86_INS_KMOVB, "kmovb", "r17d, k3", 4, 1);
}
{
const uint8_t b[] = {0x62, 0xf9, 0x7f, 8, 0x92, 0xd9};
ok &= ck(h, b, 6, X86_INS_KMOVD, "kmovd", "k3, r17d", 4, 4);
}
{
const uint8_t b[] = {0x62, 0xf9, 0x7c, 8, 0x92, 0xd9};
ok &= ck(h, b, 6, X86_INS_KMOVW, "kmovw", "k3, r17d", 2, 4);
}
{
const uint8_t b[] = {0x62, 0xe1, 0x7c, 8, 0x93, 0xcb};
ok &= ck(h, b, 6, X86_INS_KMOVW, "kmovw", "r17d, k3", 4, 2);
}
{
const uint8_t b[] = {0x62, 0xf9, 0xff, 8, 0x92, 0xd9};
ok &= ck(h, b, 6, X86_INS_KMOVQ, "kmovq", "k3, r17", 8, 8);
}
{
uint8_t b[] = {0x64, 0x62, 0xf9, 0, 8, 0x90, 0x11};
const uint8_t p[] = {0x7d, 0x7c, 0xfd, 0xfc};
const char *ld[] = {"k2, byte ptr fs:[r17]", "k2, word ptr fs:[r17]",
"k2, dword ptr fs:[r17]", "k2, qword ptr fs:[r17]"};
const char *st[] = {"byte ptr fs:[r17], k3", "word ptr fs:[r17], k3",
"dword ptr fs:[r17], k3", "qword ptr fs:[r17], k3"};
for (unsigned k = 0; k < 4; k++) {
b[3] = p[k];
b[5] = 0x90;
b[6] = 0x11;
ok &= ck(h, b, 7, ids[k], mn[k], ld[k], sz[k], sz[k]);
b[5] = 0x91;
b[6] = 0x19;
ok &= ck(h, b, 7, ids[k], mn[k], st[k], sz[k], sz[k]);
}
}
{
const uint8_t b[] = {0x64, 0x62, 0x99, 0xf9, 8, 0x90, 0x54, 0xa5, 0x20};
ok &= ck(h, b, sizeof(b), X86_INS_KMOVD, "kmovd",
"k2, dword ptr fs:[r29 + r28*4 + 0x20]", 4, 4);
}
{
const uint8_t b[] = {0x64, 0x62, 0x99, 0xf9, 8, 0x91, 0x5c, 0xa5, 0x20};
ok &= ck(h, b, sizeof(b), X86_INS_KMOVD, "kmovd",
"dword ptr fs:[r29 + r28*4 + 0x20], k3", 4, 4);
}
{
const uint8_t b[] = {0x67, 0x64, 0x62, 0x99, 0xf9,
8, 0x90, 0x54, 0xa5, 0x20};
ok &= ck(h, b, sizeof(b), X86_INS_KMOVD, "kmovd",
"k2, dword ptr fs:[r29d + r28d*4 + 0x20]", 4, 4);
}
{
const uint8_t b[] = {0x62, 0xf9, 0xff, 8, 0x92, 0xd9};
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT);
ok &= ck(h, b, 6, X86_INS_KMOVQ, "kmovq", "%r17, %k3", 8, 8);
cs_option(h, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
}
{
uint8_t x[] = {0x62, 0xf9, 0x7d, 8, 0x92, 0x19};
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[3] = 9;
x[5] = 0xd9;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[3] = 8;
x[2] = 0x79;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
x[2] = 0x75;
if (cs_disasm(h, x, 6, 0, 1, &i)) {
ok = false;
cs_free(i, 1);
}
}
cs_close(&h);
return ok ? 0 : 1;
}
Loading
Loading