Comparisions

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章