简体   繁体   English

在 cmp[.b] #4, #-1 之后会设置进位标志吗? [MSP430 16 位]

[英]will carry flag be set after cmp[.b] #4, #-1 ? [MSP430 16 bit]

[MSP430 16 bit] [MSP430 16 位]

0x437c    mov[.b] #-1, r12 

0x926c    cmp[.b] #4, r12 

0x2801    jlo 0xda36

Could anyone help me calculation (cmp[.b] #4, r12 ) with Binary?谁能帮我用二进制计算 (cmp[.b] #4, r12 )?

Example : r12-#4= 1111111111111111 - 0100 @@?示例:r12-#4= 1111111111111111 - 0100 @@? I dont know how to calculation cmp with Binary in unsigned and signed case.我不知道如何在无符号和有符号的情况下用二进制计算 cmp。

Nothing changes between signed and unsigned subtraction.有符号和无符号减法之间没有任何变化。 What changes is what kind of jump you use: JLO or JL.改变的是你使用什么样的跳跃:JLO或JL。 JL and JGE is used for signed comparison. JL 和 JGE 用于有符号比较。 JLO and JHS are used for unsigned comparison. JLO 和 JHS 用于无符号比较。 So, in your case, you are using unsigned comparison and the jlo will not jump to 0xda36 as CMP will set the carry bit.因此,在您的情况下,您使用的是无符号比较,并且 jlo 不会跳转到 0xda36,因为 CMP 将设置进位位。 Note that JLO is an alias for JNC (jump if not carry).请注意,JLO 是 JNC 的别名(如果不进位则跳转)。

To compute manually the subraction you can traslate it to the sum of the first addend plus the one complement of the second + 1. So in you case you have:要手动计算减法,您可以将其转换为第一个加数加上第二个 + 1 的一个补数的总和。因此,在您的情况下,您有:

  0xFFFF - 0x0004 = 
  0xFFFF + 0xFFFB + 1 =  //carry is set
  0xFFFB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM