NAME=x86:LE:32:default:gcc
ARGS=-a x86
FILE=malloc://2048
EXPECT=<<EOF
            0x00000000      89e1           mov ecx, esp
type: mov
----
            0x00000000      a168a00408     mov eax, dword [0x804a068]  ; [0x804a068:4]=-1
type: mov
----
            0x00000000      a368a00408     mov dword [0x804a068], eax  ; [0x804a068:4]=-1
type: mov
----
            0x00000000      8945f0         mov dword [ebp - 0x10], eax
type: mov
----
            0x00000000      8b4510         mov eax, dword [ebp + 0x10]
type: mov
----
            0x00000000      0f4c0d0300..   cmovl ecx, dword [3]        ; [0x3:4]=3
type: cmov
----
            0x00000000      cd80           int 0x80
type: swi
----
            0x00000000      55             push ebp
type: rpush
----
            0x00000000      6a00           push 0
type: push
----
            0x00000000      5d             pop ebp
type: pop
----
            0x00000000      83f853         cmp eax, 0x53               ; 'S'
type: cmp
----
            0x00000000      85c0           test eax, eax
type: acmp
----
            0x00000000      83c410         add esp, 0x10
type: add
----
            0x00000000      81ec88100000   sub esp, 0x1088
type: sub
----
            0x00000000      f7ea           imul edx
type: mul
----
            0x00000000      f7f2           div edx
type: div
----
            0x00000000      d1e8           shr eax, 1
type: shr
----
            0x00000000      d1e0           shl eax, 1
type: shl
----
            0x00000000      d1f8           sar eax, 1
type: sar
----
            0x00000000      0b25f0ff0000   or esp, dword [0xfff0]      ; [0xfff0:4]=-1
type: or
----
            0x00000000      2325f0ff0000   and esp, dword [0xfff0]     ; [0xfff0:4]=-1
type: and
----
            0x00000000      3325f0ff0000   xor esp, dword [0xfff0]     ; [0xfff0:4]=-1
type: xor
----
            0x00000000      8703           xchg dword [ebx], eax
type: mov
EOF
CMDS=<<EOF
e asm.cpu=x86
e asm.bits=32
pdga
wx 89e1
pd 1
ao | grep type
?e ----
wx a168a00408
pd 1
ao | grep type
?e ----
wx a368a00408
pd 1
ao | grep type
?e ----
wx 8945f0
pd 1
ao | grep type
?e ----
wx 8b4510
pd 1
ao | grep type
?e ----
wx 0f4c0d03000000
pd 1
ao | grep type
?e ----
wx cd80
pd 1
ao | grep type
?e ----
wx 55
pd 1
ao | grep type
?e ----
wx 6a00
pd 1
ao | grep type
?e ----
wx 5d
pd 1
ao | grep type
?e ----
wx 83f853
pd 1
ao | grep type
?e ----
wx 85c0
pd 1
ao | grep type
?e ----
wx 83c410
pd 1
ao | grep type
?e ----
wx 81ec88100000
pd 1
ao | grep type
?e ----
wx f7ea
pd 1
ao | grep type
?e ----
wx f7f2
pd 1
ao | grep type
?e ----
wx d1e8
pd 1
ao | grep type
?e ----
wx d1e0
pd 1
ao | grep type
?e ----
wx d1f8
pd 1
ao | grep type
?e ----
wx 0b25f0ff0000
pd 1
ao | grep type
?e ----
wx 2325f0ff0000
pd 1
ao | grep type
?e ----
wx 3325f0ff0000
pd 1
ao | grep type
?e ----
wx 8703
pd 1
ao | grep type
EOF
RUN

NAME=AARCH64:LE:64:v8A:gcc
FILE=malloc://2048
EXPECT=<<EOF
            0x00000000      298947f9       ldr x9, [x9, #0xf10]
type: load
----
            0x00000200      690200f9       str x9, [x19]
type: store
EOF
CMDS=<<EOF
e asm.cpu=AARCH64:LE:64:v8A:gcc
e asm.arch=r2ghidra
wx 298947f9
pd 1
ao | grep type
?e ----
wx 690200f9 @ 0x200
pd 1 @ 0x200
ao @ 0x200| grep type
EOF
RUN

NAME=v850cmp
FILE=-
CMDS=<<EOF
e asm.cpu=v850
e asm.bits=32
e asm.arch=r2ghidra
pdga
e anal.arch
e anal.cpu
wx e731
ao 1~!pseudo
EOF
EXPECT=<<EOF
r2ghidra
address: 0x0
opcode: cmp r7, r6
esilcost: 0
disasm: cmp r7, r6
mnemonic: cmp
mask: ffff
id: 0
bytes: e731
size: 2
sign: true
type: cmp
cycles: 0
esil: r7,NUM,r6,NUM,-,1,32,1,<<,-,&,4294967287,psw,NUM,&,1,32,1,<<,-,&,r7,NUM,r6,NUM,<,DUP,3,2,PICK,<<,1,32,1,<<,-,&,DUP,5,PICK,|,1,32,1,<<,-,&,psw,=,r6,NUM,r7,NUM,DUP,3,PICK,-,1,32,1,<<,-,&,31,4,PICK,>>,1,32,1,<<,-,&,DUP,0,SWAP,>>,1,8,1,<<,-,&,31,5,PICK,>>,1,32,1,<<,-,&,DUP,0,SWAP,>>,1,8,1,<<,-,&,31,6,PICK,>>,1,32,1,<<,-,&,DUP,0,SWAP,>>,1,8,1,<<,-,&,1,2,PICK,&,1,8,1,<<,-,&,4294967291,psw,NUM,&,1,32,1,<<,-,&,5,PICK,8,PICK,-,!,!,3,PICK,7,PICK,-,!,DUP,3,PICK,&,1,8,1,<<,-,&,DUP,2,2,PICK,<<,1,32,1,<<,-,&,DUP,7,PICK,|,1,32,1,<<,-,&,psw,=,4294967293,psw,NUM,&,1,32,1,<<,-,&,0,23,PICK,32,SWAP,~,SWAP,32,SWAP,~,SWAP,<,DUP,1,2,PICK,<<,1,32,1,<<,-,&,DUP,5,PICK,|,1,32,1,<<,-,&,psw,=,4294967294,psw,NUM,&,1,32,1,<<,-,&,0,27,PICK,-,!,DUP,DUP,4,PICK,|,1,32,1,<<,-,&,psw,=
family: cpu
EOF
RUN

NAME=v850load
FILE=-
CMDS=<<EOF
e asm.cpu=v850
e asm.bits=32
e asm.arch=r2ghidra
pdga
e anal.arch
e anal.cpu
wx 3d5f0500
ao 1~!pseudo
EOF
EXPECT=<<EOF
r2ghidra
address: 0x0
opcode: ld.w 0x4[r29], r11
esilcost: 4
disasm: ld.w 0x4[r29], r11
mnemonic: ld.w
mask: ffffffff
id: 0
bytes: 3d5f0500
size: 4
sign: true
type: load
cycles: 0
esil: 4,r29,NUM,+,1,32,1,<<,-,&,DUP,[4],r11,=
family: cpu
EOF
RUN

NAME=AARCH64 esil
FILE=malloc://2048
CMDS=<<EOF
e log.level=0
e asm.cpu=AARCH64:LE:64:v8A:gcc
e asm.arch=r2ghidra
wx 298947f9
ao 1~type
ao 1~esil
?e ----
wx 690200f9
ao 1~type
ao 1~esil
EOF
EXPECT=<<EOF
type: load
esilcost: 8
esil: 3856,x9,NUM,+,1,64,1,<<,-,&,DUP,[8],x9,=
----
type: store
esilcost: 24
esil: x19,NUM,x9,NUM,2,PICK,=[8]
EOF
RUN

NAME=v850 esil
FILE=-
CMDS=<<EOF
e log.level=0
e asm.cpu=v850
e asm.bits=32
e asm.arch=r2ghidra
wx e731
ao 1~type
ao 1~esilcost
EOF
EXPECT=<<EOF
type: cmp
esilcost: 0
EOF
RUN
