为什么 CMP(比较)有时会在 8086 程序集中设置进位标志? [英] Why does CMP (compare) sometimes sets a Carry Flag in 8086 assembly?

查看:60
本文介绍了为什么 CMP(比较)有时会在 8086 程序集中设置进位标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读 8086 指令集,它说 CMP(比较)可以设置进位标志.我知道比较会减去两个操作数,但我想知道在这种情况下是否有人可以提供示例.

I've been reading around and with the 8086 Instruction Set, it says that a CMP (compare) can set the Carry Flag. I understand that a compare subtracts two operands but I was wondering if anyone can provide an example when that is the case.

我只是无法理解添加数字的想法,负数会设置进位标志.我已经阅读了借用标志,但我只需要一个示例来阐明我对比较指令的理解.

I just can't grasp the idea of adding a number and a negative number will set the carry flag. I've read into the borrow flag but I just needed an example to clarify my understanding of a compare instruction.

另外,我知道如果 3 - 5 = -2 会设置负标志......什么时候设置进位?

Also, I understand that if 3 - 5 = -2 would set the negative flag... when is carry set?

推荐答案

  • 在导致下溢或上溢的操作之后设置进位标志.例如,从 6 中减去 10 将导致下溢并设置进位标志.同样,将寄存器的最大值加 1 将导致溢出并设置进位标志.
  • 进位标志也在移位操作期间被修改,它被设置到从目标寄存器移出的最后一位的值.
  • 位测试将测试位的值放入进位旗帜.执行此操作的操作码:BT、BTC、BTR 和 BTS.
  • 直接影响进位标志的指令:CLC、CMC 和 STC.
  • 在比较期间,进位标志的设置就像两个操作数已被减去.
  • 在否定 (NEG) 期间,除非操作数是零,在这种情况下它被清除.
  • 这篇关于为什么 CMP(比较)有时会在 8086 程序集中设置进位标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆