[英]Carry flag in MSP430 is confused
"mov #10,r5\n"
"sub #1,r5\n" //test value
I run in hardware, when 'sub' exec, the Carry flag is set.我在硬件中运行,当'sub' exec 时,Carry 标志被设置。 why?
为什么?
When it comes to subtraction, the carry flag is reversed compared to addition.进行减法时,进位标志与加法相反。 If the value wraps around, carry is set to 0. If it doesn't (as in your example) it is set to 1.
如果该值环绕,则进位设置为 0。如果不是(如您的示例中所示),则将其设置为 1。
Unfortunately, this is not 100% clear when reading the processor manual.不幸的是,在阅读处理器手册时,这并不是 100% 清楚。 However, this behavior is consistent with other processors, eg 6502.
但是,这种行为与其他处理器一致,例如 6502。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.