instruction: CMP
comparing by subtraction
for unsigned numbers:
2 bits in the FLAGS register
ZF CF
= 1 0
> 0 0
< 0 1
for signed numbers:
3 bits in the FLAGS register
ZF OF SF
= 1 0 0
> 0 1/0 1/0
< 0 1/0 0/1
the way of examining overflow:
carry into MSB != carry out of MSB
if
a positive + a positive --> a negative
or
a negative + a negative --> a positive
an overflow is generated
if
a negative + a positive or a positive + a negative
there will be no overflow
博客介绍了CMP指令通过减法进行比较的方式。对于无符号数,依据FLAGS寄存器的2位(ZF、CF)判断大小;对于有符号数,依据3位(ZF、OF、SF)判断。还说明了检查溢出的方法,即MSB的进位和借位不同时产生溢出,正负相加则无溢出。
437

被折叠的 条评论
为什么被折叠?



