Skip to content

Commit 3ef0ff2

Browse files
committed
Add outsb/w/d/q
1 parent 8ea6280 commit 3ef0ff2

File tree

4 files changed

+182
-10
lines changed

4 files changed

+182
-10
lines changed

arch/X86/X86Mapping.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,35 @@ void X86_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
11131113
break;
11141114
}
11151115
break;
1116+
1117+
case X86_INS_OUTSB:
1118+
case X86_INS_OUTSW:
1119+
case X86_INS_OUTSD:
1120+
switch (h->mode) {
1121+
default:
1122+
break;
1123+
case CS_MODE_64:
1124+
arr_replace(
1125+
insn->detail->regs_read,
1126+
insn->detail->regs_read_count,
1127+
X86_REG_ESI, X86_REG_RSI);
1128+
arr_replace(
1129+
insn->detail->regs_write,
1130+
insn->detail->regs_write_count,
1131+
X86_REG_ESI, X86_REG_RSI);
1132+
break;
1133+
case CS_MODE_16:
1134+
arr_replace(
1135+
insn->detail->regs_read,
1136+
insn->detail->regs_read_count,
1137+
X86_REG_ESI, X86_REG_SI);
1138+
arr_replace(
1139+
insn->detail->regs_write,
1140+
insn->detail->regs_write_count,
1141+
X86_REG_ESI, X86_REG_SI);
1142+
break;
1143+
}
1144+
break;
11161145
}
11171146

11181147
memcpy(insn->detail->groups, insns[i].groups,

arch/X86/X86MappingInsn.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12151,21 +12151,21 @@
1215112151
{
1215212152
X86_OUTSB, X86_INS_OUTSB, 0,
1215312153
#ifndef CAPSTONE_DIET
12154-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
12154+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
1215512155
#endif
1215612156
},
1215712157

1215812158
{
1215912159
X86_OUTSL, X86_INS_OUTSD, 0,
1216012160
#ifndef CAPSTONE_DIET
12161-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
12161+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
1216212162
#endif
1216312163
},
1216412164

1216512165
{
1216612166
X86_OUTSW, X86_INS_OUTSW, 0,
1216712167
#ifndef CAPSTONE_DIET
12168-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
12168+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
1216912169
#endif
1217012170
},
1217112171

arch/X86/X86MappingInsn_reduce.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6236,21 +6236,21 @@
62366236
{
62376237
X86_OUTSB, X86_INS_OUTSB, 0,
62386238
#ifndef CAPSTONE_DIET
6239-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
6239+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
62406240
#endif
62416241
},
62426242

62436243
{
62446244
X86_OUTSL, X86_INS_OUTSD, 0,
62456245
#ifndef CAPSTONE_DIET
6246-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
6246+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
62476247
#endif
62486248
},
62496249

62506250
{
62516251
X86_OUTSW, X86_INS_OUTSW, 0,
62526252
#ifndef CAPSTONE_DIET
6253-
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
6253+
{ X86_REG_DX, X86_REG_ESI, X86_REG_EFLAGS, X86_REG_DS, 0 }, { X86_REG_ESI, 0 }, { 0 }, 0, 0
62546254
#endif
62556255
},
62566256

tests/details/x86.yaml

Lines changed: 147 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,10 @@ test_cases:
25482548
0xf3, 0x6c, # rep insb byte ptr es:[di], dx
25492549
0x6d, # insw word ptr es:[di], dx
25502550
0xf3, 0x6d, # rep insw word ptr es:[di], dx
2551+
0x6e, # outsb dx, byte ptr [si]
2552+
0xf3, 0x6e, # rep outsb dx, byte ptr [si]
2553+
0x6f, # outsw dx, word ptr [si]
2554+
0xf3, 0x6f, # rep outsb dx, word ptr [si]
25512555
]
25522556
arch: "x86"
25532557
options: [ CS_OPT_DETAIL, CS_MODE_16 ]
@@ -2806,6 +2810,42 @@ test_cases:
28062810
eflags: [ X86_EFLAGS_TEST_DF ]
28072811
regs_read: [ dx, flags, cx, es, di ]
28082812
regs_write: [ cx ]
2813+
-
2814+
asm_text: "outsb dx, byte ptr [si]"
2815+
details:
2816+
x86:
2817+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
2818+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
2819+
eflags: [ X86_EFLAGS_TEST_DF ]
2820+
regs_read: [ dx, si, flags, ds ]
2821+
regs_write: [ si ]
2822+
-
2823+
asm_text: "rep outsb dx, byte ptr [si]"
2824+
details:
2825+
x86:
2826+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
2827+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
2828+
eflags: [ X86_EFLAGS_TEST_DF ]
2829+
regs_read: [ dx, si, flags, ds, cx]
2830+
regs_write: [ si, cx ]
2831+
-
2832+
asm_text: "outsw dx, word ptr [si]"
2833+
details:
2834+
x86:
2835+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
2836+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
2837+
eflags: [ X86_EFLAGS_TEST_DF ]
2838+
regs_read: [ dx, si, flags, ds ]
2839+
regs_write: [ si ]
2840+
-
2841+
asm_text: "rep outsw dx, word ptr [si]"
2842+
details:
2843+
x86:
2844+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
2845+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
2846+
eflags: [ X86_EFLAGS_TEST_DF ]
2847+
regs_read: [ dx, si, flags, ds, cx]
2848+
regs_write: [ si, cx ]
28092849

28102850
-
28112851
input:
@@ -2839,6 +2879,11 @@ test_cases:
28392879
0xf3, 0x6c, # rep insb byte ptr es:[edi], dx
28402880
0x6d, # insd dword ptr es:[edi], dx
28412881
0xf3, 0x6d, # rep insd dword ptr es:[edi], dx
2882+
0x6e, # outsb dx, byte ptr [esi]
2883+
0xf3, 0x6e, # rep outsb dx, byte ptr [esi]
2884+
0x6f, # outsd dx, dword ptr [esi]
2885+
0xf3, 0x6f, # rep outsd dx, dword ptr [esi]
2886+
28422887
]
28432888
arch: "x86"
28442889
options: [ CS_OPT_DETAIL, CS_MODE_32 ]
@@ -3097,17 +3142,53 @@ test_cases:
30973142
eflags: [ X86_EFLAGS_TEST_DF ]
30983143
regs_read: [ dx, edi, eflags, ecx, es ]
30993144
regs_write: [ ecx ]
3145+
-
3146+
asm_text: "outsb dx, byte ptr [esi]"
3147+
details:
3148+
x86:
3149+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3150+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
3151+
eflags: [ X86_EFLAGS_TEST_DF ]
3152+
regs_read: [ dx, esi, eflags, ds ]
3153+
regs_write: [ ]
3154+
-
3155+
asm_text: "rep outsb dx, byte ptr [esi]"
3156+
details:
3157+
x86:
3158+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3159+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
3160+
eflags: [ X86_EFLAGS_TEST_DF ]
3161+
regs_read: [ dx, esi, eflags, ds, ecx ]
3162+
regs_write: [ esi, ecx ]
3163+
-
3164+
asm_text: "outsd dx, dword ptr [esi]"
3165+
details:
3166+
x86:
3167+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3168+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3169+
eflags: [ X86_EFLAGS_TEST_DF ]
3170+
regs_read: [ dx, esi, eflags, ds ]
3171+
regs_write: [ esi ]
3172+
-
3173+
asm_text: "rep outsd dx, dword ptr [esi]"
3174+
details:
3175+
x86:
3176+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3177+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3178+
eflags: [ X86_EFLAGS_TEST_DF ]
3179+
regs_read: [ dx, esi, eflags, ds, ecx ]
3180+
regs_write: [ esi, ecx ]
31003181

31013182
-
31023183
input:
31033184
name: "String instructions, 64-bit decode mode"
31043185
bytes: [
31053186
0xaa, # stosb byte ptr [rdi], al
31063187
0xf3, 0xaa, # rep stosb byte ptr [rdi], al
3107-
0xab, # stosd dword ptr [rdi], rax
3108-
0xf3, 0xab, # rep stosd dword ptr [rdi], rax
3109-
0x44, 0xab, # REX.W stosd dword ptr [rdi], rax
3110-
0xf3, 0x44, 0xab, # rep REX.W stosd dword ptr [rdi], rax
3188+
0xab, # stosd dword ptr [rdi], eax
3189+
0xf3, 0xab, # rep stosd dword ptr [rdi], eax
3190+
0x44, 0xab, # REX.W stosd dword ptr [rdi], eax
3191+
0xf3, 0x44, 0xab, # rep REX.W stosd dword ptr [rdi], eax
31113192
0xac, # lodsb al, byte ptr ds:[rsi]
31123193
0xf3, 0xac, # rep lodsb al, byte ptr ds:[rsi]
31133194
0xad, # lodsd eax, dword ptr [rsi]
@@ -3144,6 +3225,12 @@ test_cases:
31443225
0xf3, 0x6d, # rep insd dword ptr [rdi], dx
31453226
0x44, 0x6d, # REX.W insq qword ptr [rdi], dx
31463227
0xf3, 0x44, 0x6d, # rep REX.W insq qword ptr [rdi], dx
3228+
0x6e, # outsb dx, byte ptr [rsi]
3229+
0xf3, 0x6e, # rep outsb dx, byte ptr [rsi]
3230+
0x6f, # outsd dx, dword ptr [rsi]
3231+
0xf3, 0x6f, # rep outsd dx, dword ptr [rsi]
3232+
0x44, 0x6f, # REX.W outsd dx, qword ptr [rsi]
3233+
0xf3, 0x44, 0x6f, # rep REX.W outsd dx, qword ptr [rsi]
31473234
]
31483235
arch: "x86"
31493236
options: [ CS_OPT_DETAIL, CS_MODE_64 ]
@@ -3542,3 +3629,59 @@ test_cases:
35423629
eflags: [ X86_EFLAGS_TEST_DF ]
35433630
regs_read: [ dx, rdi, rflags, rcx ]
35443631
regs_write: [ rcx ]
3632+
-
3633+
asm_text: "outsb dx, byte ptr [rsi]"
3634+
details:
3635+
x86:
3636+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3637+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
3638+
eflags: [ X86_EFLAGS_TEST_DF ]
3639+
regs_read: [ dx, rsi, rflags, ds ]
3640+
regs_write: [ ]
3641+
-
3642+
asm_text: "rep outsb dx, byte ptr [rsi]"
3643+
details:
3644+
x86:
3645+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3646+
opcode: [ 0x6e, 0x00, 0x00, 0x00 ]
3647+
eflags: [ X86_EFLAGS_TEST_DF ]
3648+
regs_read: [ dx, rsi, rflags, ds, rcx ]
3649+
regs_write: [ rsi, rcx ]
3650+
-
3651+
asm_text: "outsd dx, dword ptr [rsi]"
3652+
details:
3653+
x86:
3654+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3655+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3656+
eflags: [ X86_EFLAGS_TEST_DF ]
3657+
regs_read: [ dx, rsi, rflags, ds ]
3658+
regs_write: [ rsi ]
3659+
-
3660+
asm_text: "rep outsd dx, dword ptr [rsi]"
3661+
details:
3662+
x86:
3663+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3664+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3665+
eflags: [ X86_EFLAGS_TEST_DF ]
3666+
regs_read: [ dx, rsi, rflags, ds, rcx ]
3667+
regs_write: [ rsi, rcx ]
3668+
-
3669+
asm_text: "outsd dx, dword ptr [rsi]"
3670+
details:
3671+
x86:
3672+
rex: 0x44
3673+
prefix: [ X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3674+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3675+
eflags: [ X86_EFLAGS_TEST_DF ]
3676+
regs_read: [ dx, rsi, rflags, ds ]
3677+
regs_write: [ rsi ]
3678+
-
3679+
asm_text: "rep outsd dx, dword ptr [rsi]"
3680+
details:
3681+
x86:
3682+
rex: 0x44
3683+
prefix: [ X86_PREFIX_REP, X86_PREFIX_0, X86_PREFIX_0, X86_PREFIX_0 ]
3684+
opcode: [ 0x6f, 0x00, 0x00, 0x00 ]
3685+
eflags: [ X86_EFLAGS_TEST_DF ]
3686+
regs_read: [ dx, rsi, rflags, ds, rcx ]
3687+
regs_write: [ rsi, rcx ]

0 commit comments

Comments
 (0)