当前文档版本为 v0.1.0,您可以访问当前页面的 开发中 版本以获取最近可能的更新。

add


add A, #K

指令格式

add A, #K

影响标志

C AC Z OV

伪指令

1
2
3
4
5
6
7
8
9
bit T, H
bit[4] L4
bit[3] H3
{AC, L4} = A[3:0] + K[3:0]
{T, H3} = A[6:4] + K[6:4] + AC
{C, H} = A[7] + K[7] + T
OV = C ^ T
A = {H, H3, L4}
Z = A ? 0 : 1

指令描述

累加器A和立即数K加法,结果存储到累加器A。

范例

1
2
3
4
//0xE9 + 0x1D
//C = 0, AC = 0, Z = 0, OV = 0
mov A, #0xE9    //A = 0xE9
add A, #0x1D    //A = 0x06, C = 1, AC = 1, Z = 0, OV = 0

add A, R

指令格式

add A, R

影响标志

C AC Z OV

伪指令

1
2
3
4
5
6
7
8
9
bit T, H
bit[4] L4
bit[3] H3
{AC, L4} = A[3:0] + R[3:0]
{T, H3} = A[6:4] + R[6:4] + AC
{C, H} = A[7] + R[7] + T
OV = C ^ T
A = {H, H3, L4}
Z = A ? 0 : 1

指令描述

累加器A和寄存器R加法,结果存储到累加器A。

范例

1
2
3
4
5
6
//0x20 + 0xE0
//C = 0, AC = 0, Z = 0, OV = 0
mov A, #0xE0    //A = 0xE0
mov 0x80, A     //[0x80] = 0xE0
mov A, #0x20    //A = 0x20
add A, 0x80     //A = 0x00, C = 1, AC = 0, Z = 1, OV = 0

add R, A

指令格式

add R, A

影响标志

C AC Z OV

伪指令

1
2
3
4
5
6
7
8
9
bit T, H
bit[4] L4
bit[3] H3
{AC, L4} = A[3:0] + R[3:0]
{T, H3} = A[6:4] + R[6:4] + AC
{C, H} = A[7] + R[7] + T
OV = C ^ T
R = {H, H3, L4}
Z = R ? 0 : 1

指令描述

寄存器R和累加器A加法,结果存储到寄存器R。

范例

1
2
3
4
5
6
//0x6E + 0x12
//C = 0, AC = 0, Z = 0, OV = 0
mov A, #0x6E    //A = 0x6E
mov 0x90, A     //[0x90] = 0x6E
mov A, #0x12    //A = 0x12
add 0x90, A     //[0x90] = 0x80, C = 0, AC = 1, Z = 0, OV = 1