NAME=op: nop
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 00
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=op: ajmp addr11
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a101
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000501
0x00000000
EOF
RUN

NAME=op: ljmp addr16
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 021234
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00001234
0x00000000
EOF
RUN

NAME=op: sjmp offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 8010
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000012
0x00000000
EOF
RUN

NAME=op: jmp @a+dptr
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 73
ar a=0x4
ar dptr=0x1230
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00001234
0x00000000
EOF
RUN

NAME=op: acall addr11
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b101
ar sp=0x20
wx ffffff @_idata+0x20
aes
ar pc; ar psw; ar sp
p8 3 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000501
0x00000000
0x00000022
ff0200
EOF
RUN

NAME=op: lcall addr16
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 121234
ar sp=0x20
wx ffffff @_idata+0x20
aes
ar pc; ar psw; ar sp
p8 3 @_idata+0x20
EOF
EXPECT=<<EOF
0x00001234
0x00000000
0x00000022
ff0300
EOF
RUN

NAME=op: ret
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 22
wx 002301 @_idata+0x20
ar sp=0x22
aes
ar pc; ar psw; ar sp
EOF
EXPECT=<<EOF
0x00000123
0x00000000
0x00000020
EOF
RUN

NAME=op: reti
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 32
wx 002301 @_idata+0x20
ar sp=0x22
aes
ar pc; ar psw; ar sp
EOF
EXPECT=<<EOF
0x00000123
0x00000000
0x00000020
EOF
RUN

NAME=op: push direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c030
wx 40 @_idata+0x30
ar sp=0x21
wx ffffff @_idata+0x20
aes
ar pc; ar psw; ar sp
p8 3 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0x00000022
ffff40
EOF
RUN

NAME=op: pop direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d030
ar sp=0x21
wx ff40ff @_idata+0x20
aes
ar pc; ar psw; ar sp
p8 1 @_idata+0x30
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0x00000020
40
EOF
RUN

NAME=op: jbc bit, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 100330100430
wx 10 @_idata+0x20
aes
ar pc
aes
ar pc; ar psw
pB 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
00000000
EOF
RUN

NAME=op: jb bit, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 200330200430
wx 10 @_idata+0x20
aes
ar pc
aes
ar pc; ar psw
pB 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
00010000
EOF
RUN

NAME=op: jnb bit, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 300430300330
wx 10 @_idata+0x20
aes
ar pc
aes
ar pc; ar psw
pB 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
00010000
EOF
RUN

NAME=op: jc offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c34030d34030
aes
aes
ar pc
aes
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000080
EOF
RUN

NAME=op: jnc offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d35030c35030
aes
aes
ar pc
aes
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
EOF
RUN

NAME=op: jz offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f46030e46030
aes
aes
ar pc
aes
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
EOF
RUN

NAME=op: jnz offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e47030f47030
aes
aes
ar pc
aes
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000036
0x00000000
EOF
RUN

NAME=op: cjne a, imm, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b46220b49620
ar a=0x62
aes
ar pc; ar psw
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0x00000026
0x00000080
EOF
RUN

NAME=op: cjne a, direct, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b52030b52130
wx 1112 @_idata+0x20
ar a=0x11
aes
ar pc; ar psw
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0x00000036
0x00000080
EOF
RUN

NAME=op: cjne @Ri, imm, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b71130b71030
wx 1110 @_idata+0x20
ar r1=0x20
aes
ar pc; ar psw
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0x00000036
0x00000000
EOF
RUN

NAME=op: cjne Rn, imm, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx bf1120bf1220
ar r7=0x11
aes
ar pc; ar psw
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0x00000026
0x00000080
EOF
RUN

NAME=op: djnz direct, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d52030d52030
wx 01 @_idata+0x20
aes
ar pc
p8 1 @_idata+0x20
aes
ar pc
p8 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
00
0x00000036
ff
EOF
RUN

NAME=op: djnz Rn, offset
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx df30df30
ar r7=0x01
aes
ar pc
ar r7
aes
ar pc
ar r7
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0x00000034
0x000000ff
EOF
RUN

NAME=op: setb c
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d3
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000001
0x00000080
EOF
RUN

NAME=op: setb bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d204d206
aes
aes
ar pc; ar psw
s _idata+0x20
pB 1
EOF
EXPECT=<<EOF
0x00000004
0x00000000
01010000
EOF
RUN

NAME=op: clr a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e4
ar a=18
ar P=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000000
EOF
RUN

NAME=op: clr c
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c3
ar c=1
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=op: clr bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c204c206
wx ff @_idata+0x20
aes
aes
ar pc; ar psw
s _idata+0x20
pB 1
EOF
EXPECT=<<EOF
0x00000004
0x00000000
10101111
EOF
RUN

NAME=op: cpl a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f4
ar a=0xf8
ar P=0
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000007
EOF
RUN

NAME=op: cpl c
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b3
ar c=1
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000001
0x00000000
EOF
RUN

NAME=op: cpl bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx b203b206
wx f0 @_idata+0x20
aes
aes
ar pc; ar psw
s _idata+0x20
pB 1
EOF
EXPECT=<<EOF
0x00000004
0x00000000
10111000
EOF
RUN

NAME=op: dec a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 14
ar a=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000000
EOF
RUN

NAME=op: dec direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 1520
wx 80 @_idata+0x20
aes
ar pc; ar psw
s _idata+0x20
p8 1
EOF
EXPECT=<<EOF
0x00000002
0x00000000
7f
EOF
RUN

NAME=op: dec @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 16
ar r0=0x20
wx 80 @_idata+0x20
aes
ar pc; ar psw
s _idata+0x20
p8 1
EOF
EXPECT=<<EOF
0x00000001
0x00000000
7f
EOF
RUN

NAME=op: dec Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 1f
ar r7=0x80
aes
ar pc; ar psw; ar r7
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x0000007f
EOF
RUN

NAME=op: inc a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 04
ar a=0xff
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000000
EOF
RUN

NAME=op: inc direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 0520
wx 80 @_idata+0x20
aes
ar pc; ar psw
s _idata+0x20
p8 1
EOF
EXPECT=<<EOF
0x00000002
0x00000000
81
EOF
RUN

NAME=op: inc @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 06
ar r0=0x20
wx 80 @_idata+0x20
aes
ar pc; ar psw
s _idata+0x20
p8 1
EOF
EXPECT=<<EOF
0x00000001
0x00000000
81
EOF
RUN

NAME=op: inc Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 0f
ar r7=0x80
aes
ar pc; ar psw; ar r7
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000081
EOF
RUN

NAME=op: inc dptr
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a3
ar dptr=0xff
aes
ar pc; ar psw; ar dptr
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000100
EOF
RUN

NAME=op: add a, imm (carry)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 2480
ar a=0x80
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000080
0x00000000
EOF
RUN

NAME=op: add a, imm (aux carry)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 2408
ar a=0x08
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000041
0x00000010
EOF
RUN

NAME=op: add a, imm (overflow)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 2440
ar a=0x40
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000005
0x00000080
EOF
RUN

NAME=op: add a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 2520
ar a=0x81
wx 2030 @_idata+0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x000000a1
EOF
RUN

NAME=op: add a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 27
ar a=0x81
ar r1=0x20
wx 2030 @_idata+0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000a1
EOF
RUN

NAME=op: add a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 2f
ar a=0x81
ar r7=0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000a1
EOF
RUN

NAME=op: addc a, imm (carry)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 3480
ar a=0x80
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000081
0x00000001
EOF
RUN

NAME=op: addc a, imm (aux carry)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 3408
ar a=0x08
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000040
0x00000011
EOF
RUN

NAME=op: addc a, imm (overflow)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 3440
ar a=0x40
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000004
0x00000081
EOF
RUN

NAME=op: addc a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 3520
ar a=0x81
ar c=1
wx 2030 @_idata+0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x000000a2
EOF
RUN

NAME=op: addc a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 37
ar a=0x81
ar r1=0x20
ar c=1
wx 2030 @_idata+0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000a2
EOF
RUN

NAME=op: addc a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 3f
ar a=0x81
ar r7=0x20
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000a2
EOF
RUN

NAME=op: subb a, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c37462949674279412
aes
aes
aes
ar pc; ar psw; ar a
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000005
0x000000c0
0x000000cc
0x00000009
0x00000000
0x00000014
EOF
RUN

NAME=op: subb a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c37462952074279521
wx 9612 @_idata+0x20
aes
aes
aes
ar pc; ar psw; ar a
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000005
0x000000c0
0x000000cc
0x00000009
0x00000000
0x00000014
EOF
RUN

NAME=op: subb a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 7920c374629709742797
wx 9612 @_idata+0x20
aes
aes
aes
aes
ar pc; ar psw; ar a
aes
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000006
0x000000c0
0x000000cc
0x0000000a
0x00000000
0x00000014
EOF
RUN

NAME=op: subb a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c374627f969f74277f129f
aes
aes
aes
aes
ar pc; ar psw; ar a
aes
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000006
0x000000c0
0x000000cc
0x0000000b
0x00000000
0x00000014
EOF
RUN

NAME=op: da a (BCD no carry: 23+23)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 74232423d4
aes
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000005
0x00000001
0x00000046
EOF
RUN

NAME=op: da a (BCD with carry #1: 99+99)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 74992499d4
aes
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000005
0x000000c1
0x00000098
EOF
RUN

NAME=op: da a (BCD with carry #2: 99+66)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 74992466d4
aes
aes
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000005
0x00000080
0x00000065
EOF
RUN

NAME=op: div ab
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 848484
ar a=106
ar b=3
aes
ar pc; ar psw; ar a; ar b
aes
ar pc; ar psw; ar a; ar b
aes
ar pc; ar ov;
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000023
0x00000001
0x00000002
0x00000001
0x00000023
0x00000000
0x00000003
0x00000001
EOF
RUN

NAME=op: mul ab
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a4a4
ar a=32
ar b=7
aes
ar pc; ar psw; ar a; ar b
ar b=3
aes
ar pc; ar psw; ar a; ar b
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000e0
0x00000000
0x00000002
0x00000004
0x000000a0
0x00000002
EOF
RUN

NAME=op: orl direct, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 4220
wx 3040 @_idata+0x20
ar a=0x81
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
b140
EOF
RUN

NAME=op: orl direct, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 432081
wx 3040 @_idata+0x20
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000000
b140
EOF
RUN

NAME=op: orl a, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 4483
ar a=0x30
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x000000b3
EOF
RUN

NAME=op: orl a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 4520
wx 3040 @_idata+0x20
ar a=0x83
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x000000b3
EOF
RUN

NAME=op: orl a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 47
wx 3040 @_idata+0x20
ar r1=0x20
ar a=0x83
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000b3
EOF
RUN

NAME=op: orl a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 4f
ar r7=0x30
ar a=0x83
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000b3
EOF
RUN

NAME=op: orl c, bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 7203
wx 08 @_idata+0x20
aes
ar pc; ar psw;
EOF
EXPECT=<<EOF
0x00000002
0x00000080
EOF
RUN

NAME=op: orl c, /bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a003
wx 80 @_idata+0x20
aes
ar pc; ar psw;
EOF
EXPECT=<<EOF
0x00000002
0x00000080
EOF
RUN

NAME=op: anl direct, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 5220
wx 3040 @_idata+0x20
ar a=0x10
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
1040
EOF
RUN

NAME=op: anl direct, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 532010
wx 3040 @_idata+0x20
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000000
1040
EOF
RUN

NAME=op: anl a, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 5410
ar a=0x30
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000010
EOF
RUN

NAME=op: anl a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 5520
wx 3040 @_idata+0x20
ar a=0x10
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000010
EOF
RUN

NAME=op: anl a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 57
wx 3040 @_idata+0x20
ar r1=0x20
ar a=0x10
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000010
EOF
RUN

NAME=op: anl a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 5f
ar r7=0x30
ar a=0x10
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000010
EOF
RUN

NAME=op: anl c, bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d38203
wx 08 @_idata+0x20
aes
aes
ar pc; ar psw;
EOF
EXPECT=<<EOF
0x00000003
0x00000080
EOF
RUN

NAME=op: anl c, /bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d3b003
wx 08 @_idata+0x20
aes
aes
ar pc; ar psw;
EOF
EXPECT=<<EOF
0x00000003
0x00000000
EOF
RUN

NAME=op: xrl direct, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 6220
wx 3040 @_idata+0x20
ar a=0x31
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0140
EOF
RUN

NAME=op: xrl direct, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 632031
wx 3040 @_idata+0x20
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0140
EOF
RUN

NAME=op: xrl a, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 6430
ar a=0x31
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000001
EOF
RUN

NAME=op: xrl a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 6520
wx 3040 @_idata+0x20
ar a=0x31
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000001
EOF
RUN

NAME=op: xrl a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 67
wx 3040 @_idata+0x20
ar r1=0x20
ar a=0x31
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000001
EOF
RUN

NAME=op: xrl a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 6f
ar r7=0x30
ar a=0x31
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000001
EOF
RUN

NAME=op: rr a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 03
ar a=0x89
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x000000c4
EOF
RUN

NAME=op: rrc a (carry set)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 13
ar a=0x18
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x0000008c
EOF
RUN

NAME=op: rrc a (carry clear)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 13
ar a=0x99
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000081
0x0000004c
EOF
RUN

NAME=op: rl a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 23
ar a=0x89
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000013
EOF
RUN

NAME=op: rlc a (carry set)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 33
ar a=0x18
ar c=1
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000031
EOF
RUN

NAME=op: rlc a (carry clear)
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 33
ar a=0x99
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000081
0x00000032
EOF
RUN

NAME=op: mov a, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 7420
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000020
EOF
RUN

NAME=op: mov direct, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 752021
wx 3040 @_idata+0x20
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000000
2140
EOF
RUN

NAME=op: mov @Ri imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 7720
wx 3040 @_idata+0x20
ar r1=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
3020
EOF
RUN

NAME=op: mov Rn, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 7f20
aes
ar pc; ar psw; ar r7
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0x00000020
EOF
RUN

NAME=op: mov direct, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 852021
wx 3040 @_idata+0x20
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000003
0x00000000
3030
EOF
RUN

NAME=op: mov direct, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 8720
wx 3040 @_idata+0x20
ar r1=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
4040
EOF
RUN

NAME=op: mov direct, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 8f20
wx 3040 @_idata+0x20
ar r7=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
2140
EOF
RUN

NAME=op: mov dptr, imm
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 902010
aes
ar pc; ar psw; ar dptr
EOF
EXPECT=<<EOF
0x00000003
0x00000000
0x00002010
EOF
RUN

NAME=op: mov bit, c
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d39203c39204
wx f0 @_idata+0x20
ar c=1
aes 4
ar pc; ar psw
pB 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000006
0x00000000
11101000
EOF
RUN

NAME=op: mov c, bit
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a203
wx 08 @_idata+0x20
aes
ar pc; ar psw
EOF
EXPECT=<<EOF
0x00000002
0x00000080
EOF
RUN

NAME=op: mov @Ri direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx a720
wx 3040 @_idata+0x20
ar r1=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
3030
EOF
RUN

NAME=op: mov Rn, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx af20
wx 3040 @_idata+0x20
ar r7=0x21
aes
ar pc; ar psw; ar r7
EOF
EXPECT=<<EOF
0x00000002
0x00000000
0x00000030
EOF
RUN

NAME=op: mov a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e521
wx 3040 @_idata+0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000040
EOF
RUN

NAME=op: mov a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e7
wx 3040 @_idata+0x20
ar r1=0x21
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000040
EOF
RUN

NAME=op: mov a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx ef
ar r7=0x20
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000020
EOF
RUN

NAME=op: mov direct, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f520
wx 3040 @_idata+0x20
ar a=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000000
2140
EOF
RUN

NAME=op: mov @Ri, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f7
wx 3040 @_idata+0x20
ar a=0x20
ar r1=0x21
aes
ar pc; ar psw;
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000001
0x00000000
3020
EOF
RUN

NAME=op: mov Rn, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx ff
ar a=0x20
aes
ar pc; ar psw; ar r7
EOF
EXPECT=<<EOF
0x00000001
0x00000000
0x00000020
EOF
RUN

NAME=op: movx a, @dptr
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e0
wx 10 @_xdata+0x100
ar dptr=0x100
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000010
EOF
RUN

NAME=op: movx a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx e3
wx 3040 @_xdata+0x020
ar r1=0x21
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000040
EOF
RUN

NAME=op: movx @dptr, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f0
wx 10 @_xdata+0x100
ar dptr=0x100
ar a=0x20
aes
ar pc; ar psw;
p8 1 @_xdata+0x100
EOF
EXPECT=<<EOF
0x00000001
0x00000000
20
EOF
RUN

NAME=op: movx @Ri, a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx f3
wx 10 @_xdata+0x010
ar r1=0x10
ar a=0x20
aes
ar pc; ar psw;
p8 1 @_xdata+0x010
EOF
EXPECT=<<EOF
0x00000001
0x00000000
20
EOF
RUN

NAME=op: movc a, @a+pc
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 83
wx 10 @0xf0
ar a=0xf0
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000010
EOF
RUN

NAME=op: movc a, @a+dptr
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx 93
wx 10 @0x100
ar a=1
ar dptr=0xff
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000010
EOF
RUN

NAME=op: swap a
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c4
ar a=0x31
aes
ar pc; ar psw; ar a
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000013
EOF
RUN

NAME=op: xch a, direct
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c521
wx 3040 @_idata+0x20
ar a=0x20
aes
ar pc; ar psw; ar a
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000002
0x00000001
0x00000040
3020
EOF
RUN

NAME=op: xch a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx c7
wx 3040 @_idata+0x20
ar r1=0x21
ar a=0x20
aes
ar pc; ar psw; ar a
p8 2 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000040
3020
EOF
RUN

NAME=op: xch a, Rn
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx cf
ar r7=0x40
ar a=0x20
aes
ar pc; ar psw; ar a; ar r7
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000040
0x00000020
EOF
RUN

NAME=op: xchd a, @Ri
FILE=malloc://0x10000
CMDS=<<EOF
e asm.arch=8051;e asm.bits=8; aei
wx d7
wx 34 @_idata+0x20
ar r1=0x20
ar a=0x56
aes
ar pc; ar psw; ar a
p8 1 @_idata+0x20
EOF
EXPECT=<<EOF
0x00000001
0x00000001
0x00000054
36
EOF
RUN
