NAME=M68k analysis
FILE=bins/smd/LiquidSpaceDodgerV3.bin
CMDS=<<EOF
ao @ 0x00000230~jump[1]
echo ---
iI
echo ---
e asm.pseudo=true
af
pif
EOF
EXPECT=<<EOF
0x000009f2
---
arch     m68k
cpu      N/A
features N/A
baddr    0x00000000
binsz    0x000272f8
bintype  N/A
bits     32
class    SEGA MEGASIS    
compiler N/A
dbg_file N/A
endian   BE
hdr.csum N/A
guid     N/A
intrp    N/A
laddr    0x00000000
lang     N/A
machine  Sega Megadrive
maxopsz  22
minopsz  2
os       smd
cc       N/A
pcalign  2
rpath    N/A
subsys   
stripped false
havecode true
va       true
static   true
linenum  false
lsyms    false
canary   false
pie      false
relrocs  false
nx       false
---
d0 = 0xa10001
d0 &= 0xf
if (==) goto 0x216
0xa14000 = 0x53454741
sr = 0x2700
0xa11100 = 0x100
0xa11200 = 0x100
a7 = sym.SSP
call 0x9f2
call 0xa72
call 0x9ca
call 0xa86
a5 = 0x2338
d4 = 0xbff
(a3) = 0x40000000
call 0x9ea
a5 = 0x1db6
(a3) = 0xc0000000
d4 = 0x2f
call 0x9ea
call 0xae0
a5 = 0x3b38
(a3) = 0x5c000000
d4 = 0x11ff
call 0x9ea
a5 = 0x5f38
d4 = section..header
(a3) = 0x58000000
call 0x9ea
a5 = 0x6138
d4 = 0x24d0
(a3) = 0x40000001
call 0x9ea
a5 = 0xaad8
d4 = 0x7ff
(a3) = 0x40000003
call 0xa9a
a5 = 0x2276
d4 = 0
(a3) = 0x60000002
call 0x9a2
0xff0022 = 0x1
call 0x1c94
0xff000e = 0x110
0xff002e = 0xee
0xff001e = 0x5
0xff0030 = 0xff
0xff0022 = 0x1
0xff0020 = 0x1
call 0xa2e
sr = 0x2300
0xff0014 = 0x0
call 0x490
call 0x3d0
call 0xdd6
call 0x36c
call 0x4d4
call 0x6d0
call 0x1b8c
0xff000a = 0xff
0x1 += 0xff0014
call 0x472
0xff000a == 0
if (!=) goto 0x33e
goto 0x312
EOF
RUN

NAME=M68K FPU analysis has no RzIL
FILE=malloc://16
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=68020
wx f2000522f3107001
aoj~{.[]\|{opcode,family,type,opex}}
aoj~{.[]\|{rzil}}
s 4
aoj~{.[]\|{opcode,family,type,opex}}
aoj~{.[]\|{rzil}}
s 6
aoj~{[0].rzil.opcode}
e asm.cpu=cfv1
wx 04c2 @ 8
s 8
aoj~{[0].rzil.opcode}
EOF
EXPECT=<<EOF
[{"opcode":"fadd fp1, fp2","family":"fpu","type":"add","opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}}]
[{}]
[{"opcode":"fsave (a0)","family":"fpu","type":"store","opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}}]
[{}]
seq
seq
EOF
RUN

NAME=M68k extended and packed FPU operand analysis
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=68040
e asm.lines=false
wx f23c48003fff00008000000000000000f23c4c00002500012345678901234567f2104c00f2116c7bf2127d30
aoj 5~{.[]\|{bytes,size,opcode,type,family,refptr,opex}}
EOF
EXPECT=<<EOF
[{"bytes":"f23c48003fff00008000000000000000","size":16,"opcode":"fmove.x 0e1, fp0","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"fp_extended","sign_exp":16383,"reserved":0,"significand":-9223372036854775808},{"type":"reg","value":"fp0"}]}},{"bytes":"f23c4c00002500012345678901234567","size":16,"opcode":"fmove.p 0e1.2345678901234567e+025, fp0","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"fp_packed","header":2424833,"fraction":2541551402847782247},{"type":"reg","value":"fp0"}]}},{"bytes":"f2104c00","size":4,"opcode":"fmove.p (a0), fp0","type":"load","family":"fpu","refptr":0,"opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0},{"type":"reg","value":"fp0"}]}},{"bytes":"f2116c7b","size":4,"opcode":"fmove.p fp0, (a1){-5}","type":"store","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp0"},{"type":"mem","address_mode":3,"base_reg":"a1","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0},{"type":"imm","value":-5}]}},{"bytes":"f2127d30","size":4,"opcode":"fmove.p fp2, (a2){d3}","type":"store","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp2"},{"type":"mem","address_mode":3,"base_reg":"a2","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0},{"type":"reg","value":"d3"}]}}]
EOF
RUN

NAME=m68k regs
FILE=
CMDS=<<EOF
e asm.arch=m68k
ar
EOF
EXPECT=<<EOF
d0 = 0x00000000
d1 = 0x00000000
d2 = 0x00000000
d3 = 0x00000000
d4 = 0x00000000
d5 = 0x00000000
d6 = 0x00000000
d7 = 0x00000000
a0 = 0x00000000
a1 = 0x00000000
a2 = 0x00000000
a3 = 0x00000000
a4 = 0x00000000
a5 = 0x00000000
a6 = 0x00000000
a7 = 0x00000000
pc = 0x00000000
fpcr = 0x00000000
fpsr = 0x00000000
fpiar = 0x00000000
sr = 0x0000
sfc = 0x00000000
dfc = 0x00000000
vbr = 0x00000000
cacr = 0x00000000
caar = 0x00000000
msp = 0x00000000
isp = 0x00000000
tc = 0x00000000
itt0 = 0x00000000
itt1 = 0x00000000
dtt0 = 0x00000000
dtt1 = 0x00000000
mmusr = 0x00000000
urp = 0x00000000
srp = 0x0000000000000000
tt0 = 0x00000000
tt1 = 0x00000000
crp = 0x0000000000000000
acc = 0x00000000
acc0 = 0x00000000
acc1 = 0x00000000
acc2 = 0x00000000
acc3 = 0x00000000
accext01 = 0x00000000
accext23 = 0x00000000
macsr = 0x00000000
mask = 0x00000000
usp = 0x00000000
cp_external_data = 0x00000000
EOF
RUN

NAME=M68k ColdFire integer analysis
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=cfv4e
e asm.lines=false
(pdjp n;echo `pdj ${n}~{.[]\|{offset,bytes,size,opcode,family,type,jump,fail}}`~{})
wx d080d1c00680000000015280d180c080028000000001e180e080660260fe61ff000000104ac0b080b1c00c80000000014c4028024c402401b1800a800000000148c049c04ed04e904ebafffc4eb9000000104ef9000000104e500004e188e08841d048502000204048d000037001c1c0c0c0448040804e71468080800080000000014e754e7350c0908091c00480000000015380918048404e404a804e58731071c04c80a293a2a900c002c104c2f42840e746fc04d2fb10fbd0000351fcfcc00050fc802123fd802123fc000e00e358e258
.(pdjp 74)
echo -- operand helper opex --
s 0
wx 4c4028024c40240150c051c0fc802123fd802123fc000e00
aoj 7~{.[]\|{offset,bytes,size,opcode,type,family,stackop,stackptr,opex}}
EOF
EXPECT=<<EOF
[
  {
    "offset": 0,
    "bytes": "d080",
    "size": 2,
    "opcode": "add.l d0, d0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 2,
    "bytes": "d1c0",
    "size": 2,
    "opcode": "adda.l d0, a0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 4,
    "bytes": "068000000001",
    "size": 6,
    "opcode": "addi.l 0x1, d0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 10,
    "bytes": "5280",
    "size": 2,
    "opcode": "addq.l 0x1, d0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 12,
    "bytes": "d180",
    "size": 2,
    "opcode": "addx.l d0, d0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 14,
    "bytes": "c080",
    "size": 2,
    "opcode": "and.l d0, d0",
    "family": "cpu",
    "type": "and"
  },
  {
    "offset": 16,
    "bytes": "028000000001",
    "size": 6,
    "opcode": "andi.l 0x1, d0",
    "family": "cpu",
    "type": "and"
  },
  {
    "offset": 22,
    "bytes": "e180",
    "size": 2,
    "opcode": "asl.l 0x8, d0",
    "family": "cpu",
    "type": "shl"
  },
  {
    "offset": 24,
    "bytes": "e080",
    "size": 2,
    "opcode": "asr.l 0x8, d0",
    "family": "cpu",
    "type": "sar"
  },
  {
    "offset": 26,
    "bytes": "6602",
    "size": 2,
    "opcode": "bne.b 0x1e",
    "family": "cpu",
    "type": "cjmp",
    "jump": 30,
    "fail": 28
  },
  {
    "offset": 28,
    "bytes": "60fe",
    "size": 2,
    "opcode": "bra.b 0x1c",
    "family": "cpu",
    "type": "jmp",
    "jump": 28,
    "fail": 30
  },
  {
    "offset": 30,
    "bytes": "61ff00000010",
    "size": 6,
    "opcode": "bsr.l 0x30",
    "family": "cpu",
    "type": "call",
    "jump": 48,
    "fail": 36
  },
  {
    "offset": 36,
    "bytes": "4ac0",
    "size": 2,
    "opcode": "tas.b d0",
    "family": "cpu",
    "type": "or"
  },
  {
    "offset": 38,
    "bytes": "b080",
    "size": 2,
    "opcode": "cmp.l d0, d0",
    "family": "cpu",
    "type": "cmp"
  },
  {
    "offset": 40,
    "bytes": "b1c0",
    "size": 2,
    "opcode": "cmpa.l d0, a0",
    "family": "cpu",
    "type": "cmp"
  },
  {
    "offset": 42,
    "bytes": "0c8000000001",
    "size": 6,
    "opcode": "cmpi.l 0x1, d0",
    "family": "cpu",
    "type": "cmp"
  },
  {
    "offset": 48,
    "bytes": "4c402802",
    "size": 4,
    "opcode": "divs.l d0, d2",
    "family": "cpu",
    "type": "div"
  },
  {
    "offset": 52,
    "bytes": "4c402401",
    "size": 4,
    "opcode": "divu.l d0, d1:d2",
    "family": "cpu",
    "type": "div"
  },
  {
    "offset": 56,
    "bytes": "b180",
    "size": 2,
    "opcode": "eor.l d0, d0",
    "family": "cpu",
    "type": "xor"
  },
  {
    "offset": 58,
    "bytes": "0a8000000001",
    "size": 6,
    "opcode": "eori.l 0x1, d0",
    "family": "cpu",
    "type": "xor"
  },
  {
    "offset": 64,
    "bytes": "48c0",
    "size": 2,
    "opcode": "ext.l d0",
    "family": "cpu",
    "type": "cast"
  },
  {
    "offset": 66,
    "bytes": "49c0",
    "size": 2,
    "opcode": "extb.l d0",
    "family": "cpu",
    "type": "cast"
  },
  {
    "offset": 68,
    "bytes": "4ed0",
    "size": 2,
    "opcode": "jmp (a0)",
    "family": "cpu",
    "type": "ijmp"
  },
  {
    "offset": 70,
    "bytes": "4e90",
    "size": 2,
    "opcode": "jsr (a0)",
    "family": "cpu",
    "type": "icall"
  },
  {
    "offset": 72,
    "bytes": "4ebafffc",
    "size": 4,
    "opcode": "jsr 0x46(pc)",
    "family": "cpu",
    "type": "call",
    "jump": 70,
    "fail": 76
  },
  {
    "offset": 76,
    "bytes": "4eb900000010",
    "size": 6,
    "opcode": "jsr 0x10.l",
    "family": "cpu",
    "type": "call",
    "jump": 16,
    "fail": 82
  },
  {
    "offset": 82,
    "bytes": "4ef900000010",
    "size": 6,
    "opcode": "jmp 0x10.l",
    "family": "cpu",
    "type": "jmp",
    "jump": 16,
    "fail": 88
  },
  {
    "offset": 88,
    "bytes": "4e500004",
    "size": 4,
    "opcode": "link.w a0, 0x4",
    "family": "cpu",
    "type": "push"
  },
  {
    "offset": 92,
    "bytes": "e188",
    "size": 2,
    "opcode": "lsl.l 0x8, d0",
    "family": "cpu",
    "type": "shl"
  },
  {
    "offset": 94,
    "bytes": "e088",
    "size": 2,
    "opcode": "lsr.l 0x8, d0",
    "family": "cpu",
    "type": "shr"
  },
  {
    "offset": 96,
    "bytes": "41d0",
    "size": 2,
    "opcode": "lea.l (a0), a0",
    "family": "cpu",
    "type": "lea"
  },
  {
    "offset": 98,
    "bytes": "4850",
    "size": 2,
    "opcode": "pea.l (a0)",
    "family": "cpu",
    "type": "lea"
  },
  {
    "offset": 100,
    "bytes": "2000",
    "size": 2,
    "opcode": "move.l d0, d0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 102,
    "bytes": "2040",
    "size": 2,
    "opcode": "movea.l d0, a0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 104,
    "bytes": "48d00003",
    "size": 4,
    "opcode": "movem.l d0-d1, (a0)",
    "family": "cpu",
    "type": "store"
  },
  {
    "offset": 108,
    "bytes": "7001",
    "size": 2,
    "opcode": "moveq 0x1, d0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 110,
    "bytes": "c1c0",
    "size": 2,
    "opcode": "muls.w d0, d0",
    "family": "cpu",
    "type": "mul"
  },
  {
    "offset": 112,
    "bytes": "c0c0",
    "size": 2,
    "opcode": "mulu.w d0, d0",
    "family": "cpu",
    "type": "mul"
  },
  {
    "offset": 114,
    "bytes": "4480",
    "size": 2,
    "opcode": "neg.l d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 116,
    "bytes": "4080",
    "size": 2,
    "opcode": "negx.l d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 118,
    "bytes": "4e71",
    "size": 2,
    "opcode": "nop",
    "family": "cpu",
    "type": "nop"
  },
  {
    "offset": 120,
    "bytes": "4680",
    "size": 2,
    "opcode": "not.l d0",
    "family": "cpu",
    "type": "not"
  },
  {
    "offset": 122,
    "bytes": "8080",
    "size": 2,
    "opcode": "or.l d0, d0",
    "family": "cpu",
    "type": "or"
  },
  {
    "offset": 124,
    "bytes": "008000000001",
    "size": 6,
    "opcode": "ori.l 0x1, d0",
    "family": "cpu",
    "type": "or"
  },
  {
    "offset": 130,
    "bytes": "4e75",
    "size": 2,
    "opcode": "rts",
    "family": "cpu",
    "type": "ret"
  },
  {
    "offset": 132,
    "bytes": "4e73",
    "size": 2,
    "opcode": "rte",
    "family": "cpu",
    "type": "ret"
  },
  {
    "offset": 134,
    "bytes": "50c0",
    "size": 2,
    "opcode": "st.b d0",
    "family": "cpu",
    "type": "cmov"
  },
  {
    "offset": 136,
    "bytes": "9080",
    "size": 2,
    "opcode": "sub.l d0, d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 138,
    "bytes": "91c0",
    "size": 2,
    "opcode": "suba.l d0, a0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 140,
    "bytes": "048000000001",
    "size": 6,
    "opcode": "subi.l 0x1, d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 146,
    "bytes": "5380",
    "size": 2,
    "opcode": "subq.l 0x1, d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 148,
    "bytes": "9180",
    "size": 2,
    "opcode": "subx.l d0, d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 150,
    "bytes": "4840",
    "size": 2,
    "opcode": "swap d0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 152,
    "bytes": "4e40",
    "size": 2,
    "opcode": "trap 0x0",
    "family": "cpu",
    "type": "trap"
  },
  {
    "offset": 154,
    "bytes": "4a80",
    "size": 2,
    "opcode": "tst.l d0",
    "family": "cpu",
    "type": "cmp"
  },
  {
    "offset": 156,
    "bytes": "4e58",
    "size": 2,
    "opcode": "unlk a0",
    "family": "cpu",
    "type": "pop"
  },
  {
    "offset": 158,
    "bytes": "7310",
    "size": 2,
    "opcode": "mvs.b (a0), d1",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 160,
    "bytes": "71c0",
    "size": 2,
    "opcode": "mvz.w d0, d0",
    "family": "cpu",
    "type": "cast"
  },
  {
    "offset": 162,
    "bytes": "4c80",
    "size": 2,
    "opcode": "sats.l d0",
    "family": "cpu",
    "type": "cast"
  },
  {
    "offset": 164,
    "bytes": "a293a2a9",
    "size": 4,
    "opcode": "mac.w a1l, a2u, <<, (a3)&, d1, acc0",
    "family": "cpu",
    "type": "mul"
  },
  {
    "offset": 168,
    "bytes": "00c0",
    "size": 2,
    "opcode": "bitrev d0",
    "family": "cpu",
    "type": "undefined"
  },
  {
    "offset": 170,
    "bytes": "02c1",
    "size": 2,
    "opcode": "byterev d1",
    "family": "cpu",
    "type": "undefined"
  },
  {
    "offset": 172,
    "bytes": "04c2",
    "size": 2,
    "opcode": "ff1 d2",
    "family": "cpu",
    "type": "undefined"
  },
  {
    "offset": 174,
    "bytes": "f428",
    "size": 2,
    "opcode": "intouch (a0)",
    "family": "cpu",
    "type": "sync"
  },
  {
    "offset": 176,
    "bytes": "40e746fc04d2",
    "size": 6,
    "opcode": "strldsr.w 0x4d2",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 182,
    "bytes": "fb10",
    "size": 2,
    "opcode": "wddata.b (a0)",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 184,
    "bytes": "fbd00003",
    "size": 4,
    "opcode": "wdebug.l (a0)",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 188,
    "bytes": "51fc",
    "size": 2,
    "opcode": "tpf",
    "family": "cpu",
    "type": "trap"
  },
  {
    "offset": 190,
    "bytes": "fcc00050",
    "size": 4,
    "opcode": "cp0bcbusy 0x110",
    "family": "cpu",
    "type": "cjmp",
    "jump": 272,
    "fail": 194
  },
  {
    "offset": 194,
    "bytes": "fc802123",
    "size": 4,
    "opcode": "cp0ld.l d0, d2, 0x1, 0x123",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 198,
    "bytes": "fd802123",
    "size": 4,
    "opcode": "cp0st.l d2, d0, 0x1, 0x123",
    "family": "cpu",
    "type": "store"
  },
  {
    "offset": 202,
    "bytes": "fc000e00",
    "size": 4,
    "opcode": "cp0nop 0x8",
    "family": "cpu",
    "type": "nop"
  },
  {
    "offset": 206,
    "bytes": "e358",
    "size": 2,
    "opcode": "rol.w 0x1, d0",
    "family": "cpu",
    "type": "rol"
  },
  {
    "offset": 208,
    "bytes": "e258",
    "size": 2,
    "opcode": "ror.w 0x1, d0",
    "family": "cpu",
    "type": "ror"
  }
]
-- operand helper opex --
[{"bytes":"4c402802","size":4,"opcode":"divs.l d0, d2","type":"div","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"d2"}]}},{"bytes":"4c402401","size":4,"opcode":"divu.l d0, d1:d2","type":"div","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg_pair","reg_0":"d1","reg_1":"d2"}]}},{"bytes":"50c0","size":2,"opcode":"st.b d0","type":"cmov","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"51c0","size":2,"opcode":"sf.b d0","type":"cmov","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"fc802123","size":4,"opcode":"cp0ld.l d0, d2, 0x1, 0x123","type":"load","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"d2"},{"type":"imm","value":1},{"type":"imm","value":291}]}},{"bytes":"fd802123","size":4,"opcode":"cp0st.l d2, d0, 0x1, 0x123","type":"store","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d2"},{"type":"reg","value":"d0"},{"type":"imm","value":1},{"type":"imm","value":291}]}},{"bytes":"fc000e00","size":4,"opcode":"cp0nop 0x8","type":"nop","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"imm","value":8}]}}]
EOF
RUN

NAME=M68k ColdFire FPU analysis
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=cfv4e
e asm.lines=false
(pdjp n;echo `pdj ${n}~{.[]\|{offset,bytes,size,opcode,family,type,jump,fail}}`~{})
wx f2004000f2006000f23c44803f800000f23c5480400921fb54442d18f2105000f2106400f210d003f210f003f2800000f2800010f2c000000010f24800000010f2500000f27c0000f27a00001234f27b000012345678f200053af2000522f2000a28f2000523f2000520f2000521f2000525f2000538f2000518f200051af2000501f2000503f310f350f200051d
.(pdjp 31)
echo -- fpu operand opex --
s 0
wx f2004000f23c44803f800000f200053af2000522f2000520f2000521f2000525f2000538f2000518f200051af310f350f200051d
aoj 13~{.[]\|{offset,bytes,size,opcode,type,family,direction,refptr,opex}}
EOF
EXPECT=<<EOF
[
  {
    "offset": 0,
    "bytes": "f2004000",
    "size": 4,
    "opcode": "fmove.l d0, fp0",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 4,
    "bytes": "f2006000",
    "size": 4,
    "opcode": "fmove.l fp0, d0",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 8,
    "bytes": "f23c44803f800000",
    "size": 8,
    "opcode": "fmove.s 1.000000, fp1",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 16,
    "bytes": "f23c5480400921fb54442d18",
    "size": 12,
    "opcode": "fmove.d 3.141593, fp1",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 28,
    "bytes": "f2105000",
    "size": 4,
    "opcode": "fmove.w (a0), fp0",
    "family": "fpu",
    "type": "load"
  },
  {
    "offset": 32,
    "bytes": "f2106400",
    "size": 4,
    "opcode": "fmove.s fp0, (a0)",
    "family": "fpu",
    "type": "store"
  },
  {
    "offset": 36,
    "bytes": "f210d003",
    "size": 4,
    "opcode": "fmovem (a0), fp6-fp7",
    "family": "fpu",
    "type": "load"
  },
  {
    "offset": 40,
    "bytes": "f210f003",
    "size": 4,
    "opcode": "fmovem fp6-fp7, (a0)",
    "family": "fpu",
    "type": "store"
  },
  {
    "offset": 44,
    "bytes": "f2800000",
    "size": 4,
    "opcode": "fnop",
    "family": "fpu",
    "type": "nop"
  },
  {
    "offset": 48,
    "bytes": "f2800010",
    "size": 4,
    "opcode": "fbf.w 0x42",
    "family": "fpu",
    "type": "cjmp",
    "jump": 66,
    "fail": 52
  },
  {
    "offset": 52,
    "bytes": "f2c000000010",
    "size": 6,
    "opcode": "fbf.l 0x46",
    "family": "fpu",
    "type": "cjmp",
    "jump": 70,
    "fail": 58
  },
  {
    "offset": 58,
    "bytes": "f24800000010",
    "size": 6,
    "opcode": "fdbf d0, 0x4e",
    "family": "fpu",
    "type": "cjmp",
    "jump": 78,
    "fail": 64
  },
  {
    "offset": 64,
    "bytes": "f2500000",
    "size": 4,
    "opcode": "fsf.b (a0)",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 68,
    "bytes": "f27c0000",
    "size": 4,
    "opcode": "ftrapf",
    "family": "fpu",
    "type": "trap"
  },
  {
    "offset": 72,
    "bytes": "f27a00001234",
    "size": 6,
    "opcode": "ftrapf.w 0x1234",
    "family": "fpu",
    "type": "trap"
  },
  {
    "offset": 78,
    "bytes": "f27b000012345678",
    "size": 8,
    "opcode": "ftrapf.l 0x12345678",
    "family": "fpu",
    "type": "trap"
  },
  {
    "offset": 86,
    "bytes": "f200053a",
    "size": 4,
    "opcode": "ftst fp1, fp2",
    "family": "fpu",
    "type": "cmp"
  },
  {
    "offset": 90,
    "bytes": "f2000522",
    "size": 4,
    "opcode": "fadd fp1, fp2",
    "family": "fpu",
    "type": "add"
  },
  {
    "offset": 94,
    "bytes": "f2000a28",
    "size": 4,
    "opcode": "fsub fp2, fp4",
    "family": "fpu",
    "type": "sub"
  },
  {
    "offset": 98,
    "bytes": "f2000523",
    "size": 4,
    "opcode": "fmul fp1, fp2",
    "family": "fpu",
    "type": "mul"
  },
  {
    "offset": 102,
    "bytes": "f2000520",
    "size": 4,
    "opcode": "fdiv fp1, fp2",
    "family": "fpu",
    "type": "div"
  },
  {
    "offset": 106,
    "bytes": "f2000521",
    "size": 4,
    "opcode": "fmod fp1, fp2",
    "family": "fpu",
    "type": "mod"
  },
  {
    "offset": 110,
    "bytes": "f2000525",
    "size": 4,
    "opcode": "frem fp1, fp2",
    "family": "fpu",
    "type": "mod"
  },
  {
    "offset": 114,
    "bytes": "f2000538",
    "size": 4,
    "opcode": "fcmp fp1, fp2",
    "family": "fpu",
    "type": "cmp"
  },
  {
    "offset": 118,
    "bytes": "f2000518",
    "size": 4,
    "opcode": "fabs fp1, fp2",
    "family": "fpu",
    "type": "undefined"
  },
  {
    "offset": 122,
    "bytes": "f200051a",
    "size": 4,
    "opcode": "fneg fp1, fp2",
    "family": "fpu",
    "type": "sub"
  },
  {
    "offset": 126,
    "bytes": "f2000501",
    "size": 4,
    "opcode": "fint fp1, fp2",
    "family": "fpu",
    "type": "cast"
  },
  {
    "offset": 130,
    "bytes": "f2000503",
    "size": 4,
    "opcode": "fintrz fp1, fp2",
    "family": "fpu",
    "type": "cast"
  },
  {
    "offset": 134,
    "bytes": "f310",
    "size": 2,
    "opcode": "fsave (a0)",
    "family": "fpu",
    "type": "store"
  },
  {
    "offset": 136,
    "bytes": "f350",
    "size": 2,
    "opcode": "frestore (a0)",
    "family": "fpu",
    "type": "load"
  },
  {
    "offset": 138,
    "bytes": "f200051d",
    "size": 4,
    "opcode": "fcos fp1, fp2",
    "family": "fpu",
    "type": "mov"
  }
]
-- fpu operand opex --
[{"bytes":"f2004000","size":4,"opcode":"fmove.l d0, fp0","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"fp0"}]}},{"bytes":"f23c44803f800000","size":8,"opcode":"fmove.s 1.000000, fp1","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"fp_single","value":1.000000},{"type":"reg","value":"fp1"}]}},{"bytes":"f200053a","size":4,"opcode":"ftst fp1, fp2","type":"cmp","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000522","size":4,"opcode":"fadd fp1, fp2","type":"add","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000520","size":4,"opcode":"fdiv fp1, fp2","type":"div","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000521","size":4,"opcode":"fmod fp1, fp2","type":"mod","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000525","size":4,"opcode":"frem fp1, fp2","type":"mod","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000538","size":4,"opcode":"fcmp fp1, fp2","type":"cmp","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f2000518","size":4,"opcode":"fabs fp1, fp2","type":"undefined","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f200051a","size":4,"opcode":"fneg fp1, fp2","type":"sub","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}},{"bytes":"f310","size":2,"opcode":"fsave (a0)","type":"store","family":"fpu","refptr":0,"opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"f350","size":2,"opcode":"frestore (a0)","type":"load","family":"fpu","refptr":0,"opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"f200051d","size":4,"opcode":"fcos fp1, fp2","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}}]
EOF
RUN

NAME=M68k collapsed and packed FPU operand opex
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=68020
e asm.lines=false
wx f2000025f2007fff
aoj 2~{.[]\|{bytes,size,opcode,type,family,refptr,opex}}
EOF
EXPECT=<<EOF
[{"bytes":"f2000025","size":4,"opcode":"frem fp0","type":"mod","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp0"},{"type":"reg","value":"fp0"}]}},{"bytes":"f2007fff","size":4,"opcode":"fmove.p fp7, d0{d7}","type":"mov","family":"fpu","refptr":0,"opex":{"operands":[{"type":"reg","value":"fp7"},{"type":"reg","value":"d0"},{"type":"reg","value":"d7"}]}}]
EOF
RUN

NAME=M68k CPU32 table analysis
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=cpu32
e asm.lines=false
(pdjp n;echo `pdj ${n}~{.[]\|{offset,bytes,size,opcode,family,type,jump,fail}}`~{})
wx 4afaf8100140f8123980f8112500f8145d40
.(pdjp 5)
EOF
EXPECT=<<EOF
[
  {
    "offset": 0,
    "bytes": "4afa",
    "size": 2,
    "opcode": "bgnd",
    "family": "cpu",
    "type": "trap"
  },
  {
    "offset": 2,
    "bytes": "f8100140",
    "size": 4,
    "opcode": "tblu.w (a0), d0",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 6,
    "bytes": "f8123980",
    "size": 4,
    "opcode": "tbls.l (a2), d3",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 10,
    "bytes": "f8112500",
    "size": 4,
    "opcode": "tblun.b (a1), d2",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 14,
    "bytes": "f8145d40",
    "size": 4,
    "opcode": "tblsn.w (a4), d5",
    "family": "cpu",
    "type": "load"
  }
]
EOF
RUN
NAME=M68k CPU variant analysis
FILE==
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.lines=false
(aojp;echo `aoj~{.[]\|{opcode,bytes,size,type,family,jump,fail}}`~{})
e asm.cpu=coldfire
wx 7310
echo -- coldfire --
.(aojp)
e asm.cpu=cfv1
wx a554
echo -- cfv1 --
.(aojp)
e asm.cpu=cfv2
wx 4c402802
echo -- cfv2 --
.(aojp)
e asm.cpu=cfv3
wx f4e8
echo -- cfv3 --
.(aojp)
e asm.cpu=cfv4
wx 60ff00000010
echo -- cfv4 --
.(aojp)
e asm.cpu=cfv4e
wx a900
echo -- cfv4e --
.(aojp)
wx 71c0
echo -- cfv4e mvz --
.(aojp)
wx 4c80
echo -- cfv4e sats --
.(aojp)
wx a293a2a9
echo -- cfv4e mac-shift --
.(aojp)
wx 4ebafffc
echo -- cfv4e pc-relative --
.(aojp)
wx 4ed0
echo -- cfv4e indirect --
.(aojp)
wx f23c44803f800000
echo -- cfv4e fpu-single --
.(aojp)
e asm.cpu=cfv5
wx a0010000
echo -- cfv5 --
.(aojp)
e asm.cpu=68040
wx 4eb912345678
echo -- 68040 absolute --
.(aojp)
e asm.cpu=68020
wx f2408170f24800000001f27a00001234f27c0000f2800001f2c000000001
echo -- 68020 fpu branch opex --
aoj 6~{.[]\|{offset,bytes,size,opcode,type,family,jump,fail,opex}}
EOF
EXPECT=<<EOF
-- coldfire --
[
  {
    "opcode": "mvs.b (a0), d1",
    "bytes": "7310",
    "size": 2,
    "type": "load",
    "family": "cpu"
  }
]
-- cfv1 --
[
  {
    "opcode": "mov3q.l 0x2, (a4)",
    "bytes": "a554",
    "size": 2,
    "type": "store",
    "family": "cpu"
  }
]
-- cfv2 --
[
  {
    "opcode": "divs.l d0, d2",
    "bytes": "4c402802",
    "size": 4,
    "type": "div",
    "family": "cpu"
  }
]
-- cfv3 --
[
  {
    "opcode": "cpushl bc, (a0)",
    "bytes": "f4e8",
    "size": 2,
    "type": "sync",
    "family": "cpu"
  }
]
-- cfv4 --
[
  {
    "opcode": "bra.l 0x12",
    "bytes": "60ff00000010",
    "size": 6,
    "type": "jmp",
    "family": "cpu",
    "jump": 18,
    "fail": 6
  }
]
-- cfv4e --
[
  {
    "opcode": "move.l d0, macsr",
    "bytes": "a900",
    "size": 2,
    "type": "mov",
    "family": "cpu"
  }
]
-- cfv4e mvz --
[
  {
    "opcode": "mvz.w d0, d0",
    "bytes": "71c0",
    "size": 2,
    "type": "cast",
    "family": "cpu"
  }
]
-- cfv4e sats --
[
  {
    "opcode": "sats.l d0",
    "bytes": "4c80",
    "size": 2,
    "type": "cast",
    "family": "cpu"
  }
]
-- cfv4e mac-shift --
[
  {
    "opcode": "mac.w a1l, a2u, <<, (a3)&, d1, acc0",
    "bytes": "a293a2a9",
    "size": 4,
    "type": "mul",
    "family": "cpu"
  }
]
-- cfv4e pc-relative --
[
  {
    "opcode": "jsr 0xfffffffe(pc)",
    "bytes": "4ebafffc",
    "size": 4,
    "type": "call",
    "family": "cpu",
    "jump": 4294967294,
    "fail": 4
  }
]
-- cfv4e indirect --
[
  {
    "opcode": "jmp (a0)",
    "bytes": "4ed0",
    "size": 2,
    "type": "ijmp",
    "family": "cpu",
    "fail": 2
  }
]
-- cfv4e fpu-single --
[
  {
    "opcode": "fmove.s 1.000000, fp1",
    "bytes": "f23c44803f800000",
    "size": 8,
    "type": "mov",
    "family": "fpu"
  }
]
-- cfv5 --
[
  {
    "opcode": "mac.w d1l, d0l, acc0",
    "bytes": "a0010000",
    "size": 4,
    "type": "mul",
    "family": "cpu"
  }
]
-- 68040 absolute --
[
  {
    "opcode": "jsr 0x12345678.l",
    "bytes": "4eb912345678",
    "size": 6,
    "type": "call",
    "family": "cpu",
    "jump": 305419896,
    "fail": 6
  }
]
-- 68020 fpu branch opex --
[{"bytes":"f2408170","size":4,"opcode":"fssf.b d0","type":"mov","family":"fpu","opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"f24800000001","size":6,"opcode":"fdbf d0, 0x9","type":"cjmp","family":"fpu","jump":9,"fail":10,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"br_disp","disp":3,"disp_size":2}]}},{"bytes":"f27a00001234","size":6,"opcode":"ftrapf.w 0x1234","type":"trap","family":"fpu","opex":{"operands":[{"type":"imm","value":4660}]}},{"bytes":"f27c0000","size":4,"opcode":"ftrapf","type":"trap","family":"fpu","opex":{"operands":[]}},{"bytes":"f2800001","size":4,"opcode":"fbf.w 0x17","type":"cjmp","family":"fpu","jump":23,"fail":24,"opex":{"operands":[{"type":"br_disp","disp":1,"disp_size":2}]}},{"bytes":"f2c000000001","size":6,"opcode":"fbf.l 0x1b","type":"cjmp","family":"fpu","jump":27,"fail":30,"opex":{"operands":[{"type":"br_disp","disp":1,"disp_size":4}]}}]
EOF
RUN

NAME=M68k analysis val and opex sweep
FILE=malloc://512
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.lines=false
(pdjp n;echo `pdj ${n}~{.[]\|{offset,bytes,size,opcode,family,type,jump,fail}}`~{})
e asm.cpu=68000
s 0
wx 4280448050c04ed04ebafffc4eb9000000104e5000044e5841d048d00003700166024ac04afc4e764e704e720000e190c1008100c1404800
echo -- 68000 pd --
pd 22
echo -- 68000 pdj --
.(pdjp 22)
echo -- 68000 aoj opex --
s 0
wx 4280448050c04ed04ebafffc4eb9000000104e5000044e5841d048d00003700166024ac0
aoj 13~{.[]\|{offset,bytes,size,opcode,type,family,stackop,stackptr,opex}}
e asm.cpu=68020
s 0
wx 06d00000f2004000f23c44803f800000f23c5480400921fb54442d18f20005224c402401f310f350
echo -- 68020 pd --
pd 8
echo -- 68020 pdj --
.(pdjp 8)
echo -- 68020 aoj opex --
s 0
wx 06d00000f2004000f23c44803f800000f23c5480400921fb54442d18f2000522
aoj 5~{.[]\|{offset,bytes,size,opcode,type,family,opex}}
e asm.cpu=cfv1
s 0
wx 40e746fc04d2fc802123fd802123
echo -- cfv1 pd --
pd 3
echo -- cfv1 pdj --
.(pdjp 3)
echo -- cfv1 aoj --
s 0
wx 40e746fc04d2fc802123fd802123
aoj 3~{.[]\|{offset,bytes,size,opcode,type,family,stackop,stackptr,opex}}
e asm.cpu=cfv4e
s 0
wx 731071c0
echo -- cfv4e pd --
pd 2
echo -- cfv4e pdj --
.(pdjp 2)
echo -- cfv4e aoj --
s 0
wx 731071c0
aoj 2~{.[]\|{offset,bytes,size,opcode,type,family,opex}}
EOF
EXPECT=<<EOF
-- 68000 pd --
0x00000000      clr.l d0
0x00000002      neg.l d0
0x00000004      st.b  d0
0x00000006      jmp   (a0)
0x00000008      jsr   0x6(pc)
0x0000000c      jsr   0x10.l
0x00000012      link.w a0, 0x4
0x00000016      unlk  a0
0x00000018      lea.l (a0), a0
0x0000001a      movem.l d0-d1, (a0)
0x0000001e      moveq 0x1, d0
0x00000020      bne.b 0x24
0x00000022      tas.b d0
0x00000024      illegal 0x4afc
0x00000026      trapv
0x00000028      reset
0x0000002a      stop  0x0
0x0000002e      roxl.l 0x8, d0
0x00000030      abcd.b d0, d0
0x00000032      sbcd.b d0, d0
0x00000034      exg.l d0, d0
0x00000036      nbcd.b d0
-- 68000 pdj --
[
  {
    "offset": 0,
    "bytes": "4280",
    "size": 2,
    "opcode": "clr.l d0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 2,
    "bytes": "4480",
    "size": 2,
    "opcode": "neg.l d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 4,
    "bytes": "50c0",
    "size": 2,
    "opcode": "st.b d0",
    "family": "cpu",
    "type": "cmov"
  },
  {
    "offset": 6,
    "bytes": "4ed0",
    "size": 2,
    "opcode": "jmp (a0)",
    "family": "cpu",
    "type": "ijmp"
  },
  {
    "offset": 8,
    "bytes": "4ebafffc",
    "size": 4,
    "opcode": "jsr 0x6(pc)",
    "family": "cpu",
    "type": "call",
    "jump": 6,
    "fail": 12
  },
  {
    "offset": 12,
    "bytes": "4eb900000010",
    "size": 6,
    "opcode": "jsr 0x10.l",
    "family": "cpu",
    "type": "call",
    "jump": 16,
    "fail": 18
  },
  {
    "offset": 18,
    "bytes": "4e500004",
    "size": 4,
    "opcode": "link.w a0, 0x4",
    "family": "cpu",
    "type": "push"
  },
  {
    "offset": 22,
    "bytes": "4e58",
    "size": 2,
    "opcode": "unlk a0",
    "family": "cpu",
    "type": "pop"
  },
  {
    "offset": 24,
    "bytes": "41d0",
    "size": 2,
    "opcode": "lea.l (a0), a0",
    "family": "cpu",
    "type": "lea"
  },
  {
    "offset": 26,
    "bytes": "48d00003",
    "size": 4,
    "opcode": "movem.l d0-d1, (a0)",
    "family": "cpu",
    "type": "store"
  },
  {
    "offset": 30,
    "bytes": "7001",
    "size": 2,
    "opcode": "moveq 0x1, d0",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 32,
    "bytes": "6602",
    "size": 2,
    "opcode": "bne.b 0x24",
    "family": "cpu",
    "type": "cjmp",
    "jump": 36,
    "fail": 34
  },
  {
    "offset": 34,
    "bytes": "4ac0",
    "size": 2,
    "opcode": "tas.b d0",
    "family": "cpu",
    "type": "or"
  },
  {
    "offset": 36,
    "bytes": "4afc",
    "size": 1,
    "opcode": "invalid"
  },
  {
    "offset": 38,
    "bytes": "4e76",
    "size": 2,
    "opcode": "trapv",
    "family": "cpu",
    "type": "trap"
  },
  {
    "offset": 40,
    "bytes": "4e70",
    "size": 2,
    "opcode": "reset",
    "family": "cpu",
    "type": "null"
  },
  {
    "offset": 42,
    "bytes": "4e720000",
    "size": 4,
    "opcode": "stop 0x0",
    "family": "cpu",
    "type": "null"
  },
  {
    "offset": 46,
    "bytes": "e190",
    "size": 2,
    "opcode": "roxl.l 0x8, d0",
    "family": "cpu",
    "type": "null"
  },
  {
    "offset": 48,
    "bytes": "c100",
    "size": 2,
    "opcode": "abcd.b d0, d0",
    "family": "cpu",
    "type": "add"
  },
  {
    "offset": 50,
    "bytes": "8100",
    "size": 2,
    "opcode": "sbcd.b d0, d0",
    "family": "cpu",
    "type": "sub"
  },
  {
    "offset": 52,
    "bytes": "c140",
    "size": 2,
    "opcode": "exg.l d0, d0",
    "family": "cpu",
    "type": "xchg"
  },
  {
    "offset": 54,
    "bytes": "4800",
    "size": 2,
    "opcode": "nbcd.b d0",
    "family": "cpu",
    "type": "sub"
  }
]
-- 68000 aoj opex --
[{"bytes":"4280","size":2,"opcode":"clr.l d0","type":"mov","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"4480","size":2,"opcode":"neg.l d0","type":"sub","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"50c0","size":2,"opcode":"st.b d0","type":"cmov","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}},{"bytes":"4ed0","size":2,"opcode":"jmp (a0)","type":"ijmp","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"4ebafffc","size":4,"opcode":"jsr 0x6(pc)","type":"call","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"mem","address_mode":11,"address":0,"in_disp":0,"out_disp":0,"disp":-4,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":1}]}},{"bytes":"4eb900000010","size":6,"opcode":"jsr 0x10.l","type":"call","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"mem","address_mode":17,"address":16,"in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"4e500004","size":4,"opcode":"link.w a0, 0x4","type":"push","family":"cpu","stackptr":-4,"opex":{"operands":[{"type":"reg","value":"a0"},{"type":"imm","value":4}]}},{"bytes":"4e58","size":2,"opcode":"unlk a0","type":"pop","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"a0"}]}},{"bytes":"41d0","size":2,"opcode":"lea.l (a0), a0","type":"lea","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0},{"type":"reg","value":"a0"}]}},{"bytes":"48d00003","size":4,"opcode":"movem.l d0-d1, (a0)","type":"store","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg_bits","value":3},{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"7001","size":2,"opcode":"moveq 0x1, d0","type":"mov","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"imm","value":1},{"type":"reg","value":"d0"}]}},{"bytes":"6602","size":2,"opcode":"bne.b 0x24","type":"cjmp","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"br_disp","disp":2,"disp_size":1}]}},{"bytes":"4ac0","size":2,"opcode":"tas.b d0","type":"or","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"}]}}]
-- 68020 pd --
0x00000000      callm 0x0, (a0)
0x00000004      fmove.l d0, fp0
0x00000008      fmove.s 1.000000, fp1
0x00000010      fmove.d 3.141593, fp1
0x0000001c      fadd  fp1, fp2
0x00000020      divu.l d0, d1:d2
0x00000024      fsave (a0)
0x00000026      frestore (a0)
-- 68020 pdj --
[
  {
    "offset": 0,
    "bytes": "06d00000",
    "size": 4,
    "opcode": "callm 0x0, (a0)",
    "family": "cpu",
    "type": "icall"
  },
  {
    "offset": 4,
    "bytes": "f2004000",
    "size": 4,
    "opcode": "fmove.l d0, fp0",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 8,
    "bytes": "f23c44803f800000",
    "size": 8,
    "opcode": "fmove.s 1.000000, fp1",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 16,
    "bytes": "f23c5480400921fb54442d18",
    "size": 12,
    "opcode": "fmove.d 3.141593, fp1",
    "family": "fpu",
    "type": "mov"
  },
  {
    "offset": 28,
    "bytes": "f2000522",
    "size": 4,
    "opcode": "fadd fp1, fp2",
    "family": "fpu",
    "type": "add"
  },
  {
    "offset": 32,
    "bytes": "4c402401",
    "size": 4,
    "opcode": "divu.l d0, d1:d2",
    "family": "cpu",
    "type": "div"
  },
  {
    "offset": 36,
    "bytes": "f310",
    "size": 2,
    "opcode": "fsave (a0)",
    "family": "fpu",
    "type": "store"
  },
  {
    "offset": 38,
    "bytes": "f350",
    "size": 2,
    "opcode": "frestore (a0)",
    "family": "fpu",
    "type": "load"
  }
]
-- 68020 aoj opex --
[{"bytes":"06d00000","size":4,"opcode":"callm 0x0, (a0)","type":"icall","family":"cpu","opex":{"operands":[{"type":"imm","value":0},{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0}]}},{"bytes":"f2004000","size":4,"opcode":"fmove.l d0, fp0","type":"mov","family":"fpu","opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"fp0"}]}},{"bytes":"f23c44803f800000","size":8,"opcode":"fmove.s 1.000000, fp1","type":"mov","family":"fpu","opex":{"operands":[{"type":"fp_single","value":1.000000},{"type":"reg","value":"fp1"}]}},{"bytes":"f23c5480400921fb54442d18","size":12,"opcode":"fmove.d 3.141593, fp1","type":"mov","family":"fpu","opex":{"operands":[{"type":"fp_double","value":3.141593},{"type":"reg","value":"fp1"}]}},{"bytes":"f2000522","size":4,"opcode":"fadd fp1, fp2","type":"add","family":"fpu","opex":{"operands":[{"type":"reg","value":"fp1"},{"type":"reg","value":"fp2"}]}}]
-- cfv1 pd --
0x00000000      strldsr.w 0x4d2
0x00000006      cp0ld.l d0, d2, 0x1, 0x123
0x0000000a      cp0st.l d2, d0, 0x1, 0x123
-- cfv1 pdj --
[
  {
    "offset": 0,
    "bytes": "40e746fc04d2",
    "size": 6,
    "opcode": "strldsr.w 0x4d2",
    "family": "cpu",
    "type": "mov"
  },
  {
    "offset": 6,
    "bytes": "fc802123",
    "size": 4,
    "opcode": "cp0ld.l d0, d2, 0x1, 0x123",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 10,
    "bytes": "fd802123",
    "size": 4,
    "opcode": "cp0st.l d2, d0, 0x1, 0x123",
    "family": "cpu",
    "type": "store"
  }
]
-- cfv1 aoj --
[{"bytes":"40e746fc04d2","size":6,"opcode":"strldsr.w 0x4d2","type":"mov","family":"cpu","stackptr":-4,"opex":{"operands":[{"type":"imm","value":1234}]}},{"bytes":"fc802123","size":4,"opcode":"cp0ld.l d0, d2, 0x1, 0x123","type":"load","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"d2"},{"type":"imm","value":1},{"type":"imm","value":291}]}},{"bytes":"fd802123","size":4,"opcode":"cp0st.l d2, d0, 0x1, 0x123","type":"store","family":"cpu","stackptr":0,"opex":{"operands":[{"type":"reg","value":"d2"},{"type":"reg","value":"d0"},{"type":"imm","value":1},{"type":"imm","value":291}]}}]
-- cfv4e pd --
0x00000000      mvs.b (a0), d1
0x00000002      mvz.w d0, d0
-- cfv4e pdj --
[
  {
    "offset": 0,
    "bytes": "7310",
    "size": 2,
    "opcode": "mvs.b (a0), d1",
    "family": "cpu",
    "type": "load"
  },
  {
    "offset": 2,
    "bytes": "71c0",
    "size": 2,
    "opcode": "mvz.w d0, d0",
    "family": "cpu",
    "type": "cast"
  }
]
-- cfv4e aoj --
[{"bytes":"7310","size":2,"opcode":"mvs.b (a0), d1","type":"load","family":"cpu","opex":{"operands":[{"type":"mem","address_mode":3,"base_reg":"a0","in_disp":0,"out_disp":0,"disp":0,"scale":0,"bitfield":0,"width":0,"offset":0,"index_size":0,"in_disp_size":0,"out_disp_size":0,"disp_size":0},{"type":"reg","value":"d1"}]}},{"bytes":"71c0","size":2,"opcode":"mvz.w d0, d0","type":"cast","family":"cpu","opex":{"operands":[{"type":"reg","value":"d0"},{"type":"reg","value":"d0"}]}}]
EOF
RUN

NAME=M68k analysis edge ops
FILE=malloc://16
CMDS=<<EOF
e asm.arch=m68k
e asm.bits=32
e asm.cpu=68000
wx 4afc
ao~type
echo ---
iI~minopsz
iI~maxopsz
iI~pcalign
EOF
EXPECT=<<EOF
type: ill
    - type: "imm"
---
minopsz  2
maxopsz  22
pcalign  2
EOF
RUN

NAME=M68k default CPU decoding matches 68040
FILE=malloc://16
ARGS=-a m68k -b 32 -E big
CMDS=<<EOF
wx f61000000001
echo -- implicit CPU --
pdj 1~{[0].opcode}
aoj 1~{[0].opcode}
aoj 1~{[0].size}
e asm.cpu=
echo -- empty CPU --
pdj 1~{[0].opcode}
aoj 1~{[0].opcode}
aoj 1~{[0].size}
e asm.cpu=default
echo -- default CPU --
pdj 1~{[0].opcode}
aoj 1~{[0].opcode}
aoj 1~{[0].size}
e asm.cpu=68040
echo -- 68040 CPU --
pdj 1~{[0].opcode}
aoj 1~{[0].opcode}
aoj 1~{[0].size}
EOF
EXPECT=<<EOF
-- implicit CPU --
move16 (a0), 0x1.l
move16 (a0), 0x1.l
6
-- empty CPU --
move16 (a0), 0x1.l
move16 (a0), 0x1.l
6
-- default CPU --
move16 (a0), 0x1.l
move16 (a0), 0x1.l
6
-- 68040 CPU --
move16 (a0), 0x1.l
move16 (a0), 0x1.l
6
EOF
RUN
