NAME=2step push x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
.aer*
"wa mov eax, 0x1234;push eax"
2aes
.aer*
aer?esp
?v [esp]
EOF
EXPECT=<<EOF
0x00107ffc
0x1234
EOF
RUN

NAME=movsb 1 byte x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 12 @ 0x10000000
aeim 0x20000000 10 destination
aer edi=0x20000000
aer esi=0x10000000
.aer*
"wx a4"
2aes
.aer*
aer?edi
aer?esi
pv @0x20000000
EOF
EXPECT=<<EOF
0x20000001
0x10000001
0x00000012
EOF
RUN

NAME=mov eax, 1 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
.aer*
"wx b801000000"
1aes
.aer*
aer?eax
EOF
EXPECT=<<EOF
0x00000001
EOF
RUN

NAME=rep movsb string x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 1234567890 @ 0x10000000
aeim 0x20000000 10 destination
aer edi=0x20000000
aer esi=0x10000000
aer ecx=10
.aer*
"wx f3a4"
aes
.aer*
aer?edi
aer?esi
pv @0x20000000
aer?ecx
EOF
EXPECT=<<EOF
0x2000000a
0x1000000a
0x78563412
0x00000000
EOF
RUN

NAME=mov byte [0x20000000], 0x64 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
wx 1234567890 @ 0x10000000
aeim 0x20000000 10 destination
.aer*
"wx c6050000002064"
aes
.aer*
pv @0x20000000
EOF
EXPECT=<<EOF
0x00000064
EOF
RUN

NAME=mov eax, [esp + 4] x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 10 destination
aer esp=0x20000000
wx 3713 @ 0x20000004
.aer*
"wx 8b442404"
aes
.aer*
aer?eax
EOF
EXPECT=<<EOF
0x00001337
EOF
RUN

NAME=mov [esp + 4], eax x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 10 destination
aer esp=0x20000000
aer eax=0x1337
.aer*
"wx 89442404"
aes
.aer*
pv @ 0x20000004
EOF
EXPECT=<<EOF
0x00001337
EOF
RUN

NAME=rep movsb 0x1000 randombytes x86-32
FILE=-
BROKEN=1
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 0x1000 source
aeim 0x20000000 0x1000 destination
wr 0x1000 @ 0x10000000
aer edi=0x20000000
aer esi=0x10000000
aer ecx=0x1000
.aer*
"wx f3a4"
aes
.aer*
s 0x10000000
cX 0x20000000
aer?edi
aer?esi
aer?ecx
EOF
EXPECT=<<EOF
0x20001000
0x10001000
0x00000000
EOF
RUN

NAME=lodsb ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 12 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fcac"
2aes
.aer*
aer?esi
aer?al
EOF
EXPECT=<<EOF
0x10000001
0x00000012
EOF
RUN

NAME=lodsb -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 12 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fdac"
2aes
.aer*
aer?esi
aer?al
EOF
EXPECT=<<EOF
0x0fffffff
0x00000012
EOF
RUN

NAME=lodsw ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 3412 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fc66ad"
2aes
.aer*
aer?esi
aer?ax
EOF
EXPECT=<<EOF
0x10000002
0x00001234
EOF
RUN

NAME=lodsw -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 3412 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fd66ad"
2aes
.aer*
aer?esi
aer?ax
EOF
EXPECT=<<EOF
0x0ffffffe
0x00001234
EOF
RUN

NAME=lodsd ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 563412 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fcad"
2aes
.aer*
aer?esi
aer?eax
EOF
EXPECT=<<EOF
0x10000004
0x00123456
EOF
RUN

NAME=lodsd -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
wx 563412 @ 0x10000000
aer esi=0x10000000
.aer*
"wx fdad"
2aes
.aer*
aer?esi
aer?eax
EOF
EXPECT=<<EOF
0x0ffffffc
0x00123456
EOF
RUN

NAME=stosb ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer al=0x12
aer edi=0x10000000
.aer*
"wx fcaa"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x10000001
0x00000012
EOF
RUN

NAME=stosb -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer al=0x12
aer edi=0x10000000
.aer*
"wx fdaa"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x0fffffff
0x00000012
EOF
RUN

NAME=stosw ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer ax = 0x1234
aer edi=0x10000000
.aer*
"wx fc66ab"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x10000002
0x00001234
EOF
RUN

NAME=stosw -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer ax = 0x1234
aer edi=0x10000000
.aer*
"wx fd66ab"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x0ffffffe
0x00001234
EOF
RUN

NAME=stosd ++ x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer eax = 0x123456
aer edi=0x10000000
.aer*
"wx fcab"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x10000004
0x00123456
EOF
RUN

NAME=stosd -- x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer eax = 0x123456
aer edi=0x10000000
.aer*
"wx fdab"
2aes
.aer*
aer?edi
pv @0x10000000
EOF
EXPECT=<<EOF
0x0ffffffc
0x00123456
EOF
RUN

NAME=shr eax(9) >> 1 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer eax = 9
aer edi=0x10000000
.aer*
"wx d1e8"
1aes
.aer*
aer?eax
aer?cf
EOF
EXPECT=<<EOF
0x00000004
0x00000001
EOF
RUN

NAME=shr eax(0x1b) >> 1 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer eax = 0x1b
aer edi=0x10000000
.aer*
"wx d1e8"
1aes
.aer*
aer?eax
aer?cf
EOF
EXPECT=<<EOF
0x0000000d
0x00000001
EOF
RUN

NAME=shr eax(5) >> 2 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aeim 0x10000000 10 source
aer eax = 5
aer edi=0x10000000
.aer*
"wx c1e802"
1aes
.aer*
aer?eax
aer?cf
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=shr byte [esp + 4], 2 x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x10000000 10 source
aer esp=0x10000000
wx 05 @ 0x10000004
.aer*
"wx c06c240402"
1aes
.aer*
pv @ 0x10000004
aer?cf
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=add byte [esp + 4], 0xa x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 10 destination
aer esp=0x20000000
wx ff @ 0x20000004
.aer*
"wx 804424040a"
aes
.aer*
pv @ 0x20000004
aer?cf
EOF
EXPECT=<<EOF
0x00000009
0x00000001
EOF
RUN

NAME=add eax, [esp + 4] x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 10 destination
aer esp=0x20000000
wx 3713 @ 0x20000004
.aer*
"wx 03442404"
aes
.aer*
aer?eax
EOF
EXPECT=<<EOF
0x00001337
EOF
RUN

NAME=add dword [0x20000000], eax x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 10 destination
aer esp=0x20000000
aer eax=0x1337
.aer*
"wx 010500000020"
aes
.aer*
pv @ 0x20000000
EOF
EXPECT=<<EOF
0x00001337
EOF
RUN

NAME=add byte cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aer dl = 0x80
.aer*
"wx 00d2"
1aes
.aer*
aer?dl
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000000
0x00000001
0x00000001
EOF
RUN

NAME=add word cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aer dx = 0x8000
.aer*
"wx 6601d2"
1aes
.aer*
aer?dx
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000000
0x00000001
0x00000001
EOF
RUN

NAME=add dword cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aer edx = 0x80000000
.aer*
"wx 01d2"
1aes
.aer*
aer?edx
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000000
0x00000001
0x00000001
EOF
RUN

NAME=adc byte cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer cf=1
aer esp=0x00108000
aer dl = 0x80
.aer*
"wx 10d2"
1aes
.aer*
aer?dl
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000000
EOF
RUN

NAME=adc word cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer cf=1
aer esp=0x00108000
aer dx = 0x8000
.aer*
"wx 6611d2"
1aes
.aer*
aer?dx
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000000
EOF
RUN

NAME=adc dword cf,zf check x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer cf=1
aer esp=0x00108000
aer edx = 0x80000000
.aer*
"wx 11d2"
1aes
.aer*
aer?edx
aer?cf
aer?zf
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000000
EOF
RUN

NAME=dec byte [edi] check zf x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer cf=1
aer esp=0x00108000
aeim 0x20000000 10 mem
aer edi = 0x20000000
wx 01 @ 0x20000000
.aer*
"wx fe0f"
1aes
.aer*
aer?zf
pv @ 0x20000000
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=dec byte [edi] check sf x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer cf=1
aer esp=0x00108000
aeim 0x20000000 10 mem
aer edi = 0x20000000
wx 00 @ 0x20000000
.aer*
"wx fe0f"
1aes
.aer*
aer?sf
pv @ 0x20000000
EOF
EXPECT=<<EOF
0x00000001
0x000000ff
EOF
RUN

NAME=inc byte [edi] check zf x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer sf=1
aer esp=0x00108000
aeim 0x20000000 10 mem
aer edi = 0x20000000
wx ff @ 0x20000000
.aer*
"wx fe07"
1aes
.aer*
aer?zf
aer?sf
pv @ 0x20000000
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000000
EOF
RUN

NAME=inc byte [edi] check sf x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer sf=1
aer esp=0x00108000
aeim 0x20000000 10 mem
aer edi = 0x20000000
wx 00 @ 0x20000000
.aer*
"wx fe07"
1aes
.aer*
aer?sf
pv @ 0x20000000
EOF
EXPECT=<<EOF
0x00000000
0x00000001
EOF
RUN

NAME=adc [esi + 0x14], ecx x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aeim 0x20000000 130 destination
aer cf = 1
aer ecx = 0x10
aer esi=0x20000000
wx 3713 @ 0x20000014
.aer*
"wx 114e14"
aes
.aer*
pv @ 0x20000014
EOF
EXPECT=<<EOF
0x00001348
EOF
RUN

NAME=div cl x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
.aer*
"wx b80500fecab202f6f2"
3aes
.aer*
aer?eax
EOF
EXPECT=<<EOF
0xcafe0102
EOF
RUN

NAME=pushal(pushad in intel documentation) x86_32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer eax=0x11111111
aer ecx=0x22222222
aer edx=0x33333333
aer ebx=0x44444444
aer esp=0x00108000
aer ebp=0x55555555
aer esi=0x66666666
aer edi=0x77777777
.aer*
"wx 60"
aes
.aer*
pv @ 0x00107ffc
pv @ 0x00107ff8
pv @ 0x00107ff4
pv @ 0x00107ff0
pv @ 0x00107fec
pv @ 0x00107fe8
pv @ 0x00107fe4
pv @ 0x00107fe0
EOF
EXPECT=<<EOF
0x11111111
0x22222222
0x33333333
0x44444444
0x00108000
0x55555555
0x66666666
0x77777777
EOF
RUN

NAME=popal(popad in intel documentation) x86_32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer eax=0x11111111
aer ecx=0x22222222
aer edx=0x33333333
aer ebx=0x44444444
aer esp=0x00108000
aer ebp=0x55555555
aer esi=0x66666666
aer edi=0x77777777
.aer*
"wx 6061"
aes
.aer*
aer eax=0x00000000
aer ecx=0x00000000
aer edx=0x00000000
aer ebx=0x00000000
aer ebp=0x00000000
aer esi=0x00000000
aer edi=0x00000000
.aer*
aes
.aer*
aer?eax
aer?ecx
aer?edx
aer?ebx
aer?esp
aer?ebp
aer?esi
aer?edi
.aer*
EOF
EXPECT=<<EOF
0x11111111
0x22222222
0x33333333
0x44444444
0x00108000
0x55555555
0x66666666
0x77777777
EOF
RUN

NAME=pop x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aer eax=0x11111111
.aer*
"wx 5058"
aes
.aer*
aer eax=0x00000000
.aer*
aes
.aer*
aer?eax
aer?esp
.aer*
EOF
EXPECT=<<EOF
0x11111111
0x00108000
EOF
RUN

NAME=pushd followed by popfd x86-32
FILE=-
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim 0 0x2000
.aer*
"wx 9c9d"
aer cf = 1
aer pf = 1
aer af = 1
aer zf = 1
aer sf = 1
aer tf = 1
aer if = 1
aer df = 1
aer of = 1
aer nt = 1
aer rf = 1
aer vm = 1
.aer*
aes
aer cf = 0
aer pf = 0
aer af = 0
aer zf = 0
aer sf = 0
aer tf = 0
aer if = 0
aer df = 0
aer of = 0
aer nt = 0
aer rf = 0
aer vm = 0
aes
.aer*
aer?cf
aer?pf
aer?af
aer?zf
aer?sf
aer?tf
aer?if
aer?df
aer?of
aer?nt
aer?rf
aer?vm
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
0x00000001
EOF
RUN

NAME=tmctf re100
FILE=bins/other/tmctf_re100
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
e io.cache=true
s 0x278
aei
aeim
aeip
13aes
*ebp+0x8 = 0x09
aesu 0x460
ps @ ebp-0x24
EOF
EXPECT=<<EOF
TMCTF{datalosswontstopus}
EOF
RUN

NAME=call [esp]
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
aei
aeim
aeip
wx b8efbeadde50ff1424
3aes
aer eip
EOF
EXPECT=<<EOF
0xdeadbeef
EOF
RUN

NAME=inline x86 pic thunk
FILE=bins/elf/redpill
CMDS=<<EOF
e asm.bytes=false
e emu.pre=true
e emu.str=true
pd 1 @ 0x1557
pd 1 @ 0x11c0
pd 1 @ 0x1523
EOF
EXPECT=<<EOF
            0x00001557      lea   eax, [esi - 0x220c]                  ; "  fwhibbit{" str.fwhibbit
            0x000011c0      lea   eax, [ebx - 0x2448]                  ; "   -os--/sosdmmNNMMNy         .+// " str.os___sosdmmNNMMNy_________.
            0x00001523      lea   eax, [esi - 0x2218]                  ; "\n  Red Pill" str.Red_Pill
EOF
RUN

NAME=aae after aF
FILE=bins/elf/redpill
CMDS=<<EOF
e asm.bytes=false
s main
aF
aae
pd 1 @ 0x1557
pd 1 @ 0x1523
EOF
EXPECT=<<EOF
|           0x00001557      lea   eax, str.fwhibbit                    ; 0x1df4 ; "  fwhibbit{"
|           0x00001523      lea   eax, str.Red_Pill                    ; 0x1de8 ; "\n  Red Pill"
EOF
RUN

NAME=cmova eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmova eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmova eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmova eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmova eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmova eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovae eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovae eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovae eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovae eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovb eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovb eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovb eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovb eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovbe eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovbe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovbe eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovbe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovc eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovc eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovc eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovc eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmove eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmove eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmove eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmove eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovg eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovg eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovg eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovg eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovge eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovge eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovge eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovge eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovl eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovl eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovl eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovl eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovle eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovle eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovle eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovle eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovle eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovle eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovna eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovna eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovna eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovna eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovna eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovna eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnae eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovnae eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnae eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnae eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnb eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnb eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnb eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovnb eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnbe eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovnbe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnbe eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovnbe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnbe eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnbe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnc eax, ecx aer cf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer cf=1
wa cmovnc eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnc eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnc eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovne eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovne eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovne eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovne eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovng eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovng eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovng eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovng eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovng eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovng eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnge eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovnge eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnge eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnge eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnl eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovnl eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnl eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnl eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnle eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnle eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnle eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovnle eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovno eax, ecx aer of=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer of=1
wa cmovno eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovno eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovno eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnp eax, ecx aer pf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer pf=1
wa cmovnp eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnp eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnp eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovns eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovns eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovns eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovns eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovnz eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovnz eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovnz eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovnz eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovo eax, ecx aer of=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer of=1
wa cmovo eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovo eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovo eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovp eax, ecx aer pf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer pf=1
wa cmovp eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovp eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovp eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovpe eax, ecx aer pf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer pf=1
wa cmovpe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovpe eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovpe eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovpo eax, ecx aer pf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer pf=1
wa cmovpo eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovpo eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovpo eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovs eax, ecx aer sf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer sf=1
wa cmovs eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovs eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovs eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=cmovz eax, ecx aer zf=1
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8
aer zf=1
wa cmovz eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000008
EOF
RUN

NAME=cmovz eax, ecx
FILE=-
ARGS=-a x86 -b 32
CMDS=<<EOF
e io.va=true
aer ecx=8

wa cmovz eax, ecx
aes
aer eax
EOF
EXPECT=<<EOF
0x00000000
EOF
RUN

NAME=push esp (push old value of esp, as in IA-32 documentation) x86_32
FILE=-
CMDS=<<EOF
e io.va=true
e asm.arch=x86
e asm.bits=32
aei
aeim
aer esp=0x00108000
aer eax=0x111111111
.aer*
"wx 5450"
2aes
.aer*
pv @ 0x00107ffc
pv @ 0x00107ff8
EOF
EXPECT=<<EOF
0x00108000
0x11111111
EOF
RUN

NAME=pdj: bts dword [esp], eax (#12575)
FILE=-
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
e io.cache=true
wx 0fab0424
pdj 1~{}
EOF
EXPECT=<<EOF
[
  {
    "offset": 0,
    "esil": "0,cf,:=,32,eax,%,1,<<,32,eax,/,esp,+,[4],&,?{,1,cf,:=,},32,eax,%,1,<<,32,eax,/,esp,+,|=[4]",
    "refptr": false,
    "fcn_addr": 0,
    "fcn_last": 0,
    "size": 4,
    "opcode": "bts dword [esp], eax",
    "disasm": "bts dword [esp], eax",
    "bytes": "0fab0424",
    "family": "cpu",
    "type": "cmp",
    "reloc": false,
    "type_num": 15,
    "type2_num": 0
  }
]

EOF
RUN

NAME=bsf reg32, reg32
CMDS=<<EOF
#
# Common parts
#
e asm.arch=x86
?== x86 `e asm.arch`
?!e asm.assembler=x86.as
??e asm.assembler=x86.nz
e asm.bits=32
wa bsf eax, ebx
#
# BSF: test ZF
#
aer eax=0x00000000
aer ebx=0x00000000
aer zf=0
aes
aer eax,zf
#
# BSF: test lowest bit
#
aeim
aer eax=0x00000000
aer ebx=0xffffffff
aer zf=0
aes
aer eax,zf
#
# BSF: test highest bit
#
aeim
aer eax=0x00000000
aer ebx=0x80000000
aer zf=0
aes
aer eax,zf
EOF
EXPECT=<<EOF
0x00000000
0x00000001
0x00000000
0x00000000
0x0000001f
0x00000000
EOF
RUN

NAME=bsr reg32, reg32
CMDS=<<EOF
#
# Common parts
#
e asm.arch=x86
e asm.assembler=x86.as
e asm.bits=32
wa bsr eax, ebx
#
# BSR: test ZF
#
aer eax=0x00000000
aer ebx=0x00000000
aer zf=0
aes
aer eax,zf
#
# BSR: test lowest bit
#
aeim
aer eax=0x00000000
aer ebx=0x00000001
aer zf=0
aes
aer eax,zf
#
# BSR: test highest bit
#
aeim
aer eax=0x00000000
aer ebx=0xffffffff
aer zf=0
aes
aer eax,zf
EOF
EXPECT=<<EOF
0x00000000
0x00000001
0x00000000
0x00000000
0x0000001f
0x00000000
EOF
RUN

NAME=cmc
FILE=-
EXPECT=<<EOF
0x00000000
0x00000001
EOF
CMDS=<<EOF
e io.va=true
e esil.debug=true
e asm.arch=x86
e asm.bits=32
aei
aeim
"wa cmc"
aer?eflags
aes
aer?eflags
EOF
RUN
