CMP 和进位标志

CMP and carry flag

处理器:MSP430 16 位 RISC

有人可以根据下面实际设置进位标志的时间来解释 CMP 指令吗?从手册上说,

CMP(.B) src,dst ..... dst - src

如果src不等于dst,是否会设置进位标志?

cmp    r15, r11
jnc    #1234

用户指南说:

Description
The source operand is subtracted from the destination operand. This is made by adding the 1s complement of the source + 1 to the destination. The result affects only the status bits in SR.
[…]
Status Bits
C: Set if there is a carry from the MSB, reset otherwise

换句话说,如果存在无符号溢出,则设置C。

这在跳转指令中也可以看出:JC(进位跳转)和JHS(高或相同跳转)是同一条指令,JNC(无进位跳转)和JLO(低进位跳转) ).

Example     If R5 ≥ R6 (unsigned), the program continues at Label2.

CMP R6,R5        ; Is R5 >= R6? Info to C
JHS Label2       ; Yes, C = 1
...              ; No, R5 < R6. Continue