简体   繁体   English

组装-标志标志和奇偶校验标志

[英]Assembly - The sign flag & parity flag

I didn't understand when the sign flag is set, and when the parity. 我不明白何时设置了标志标志以及何时设置了奇偶校验。

As I know, the sign flag indicates the sign of the result of an operation, 0 for positive numbers and 1 for negative numbers. 据我所知,符号标志表示运算结果的符号,0表示正数,1表示负数。

So why in the next code: 那么为什么在下一个代码中:

mov al, -5 
sub al, 124

The SF is zero? SF为零? The result is negative number. 结果为负数。

About the PF, Why in a and b, the PF is set? 关于PF,为什么在a和b中设置了PF?

a) sub al, al.

b) mov al, 127
   add al, 129

The code 编码

mov al, -5 
sub al, 124

calculates 256-5-124 . 计算256-5-124 It's 127 and it's positive number 是127,是正数

Both sub al, al and 127+129 evaluates to 0, it has 0 bits set, and 0 is even value, so PF is set. sub al, al127+129求值均为0,它设置了0位,并且0是偶数,因此设置了PF。

您可以用8位表示的最大数字是2 ^ 8-1,即255,因此,因为127 + 129 = 256,al将保持0,并标记:CF PF AF ZF IF将被设置,PF被如上所述设置-因为只有且仅当设置的位数为偶数时,才设置PF。

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

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