有关程序集CF(进位)和(溢)标志 [英] about assembly CF(Carry) and OF(Overflow) flag

查看:163
本文介绍了有关程序集CF(进位)和(溢)标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据了解,CF指示符号开展和指示符号溢出。那么,如何汇编程序签名和签名的数据区分开来,因为它只是一个比特序列? (通过额外的内存存储类型的信息,或通过位置信息或者别的?),可以这两个标志可以互换使用?

It's known that CF indicates unsigned carry out and OF indicates signed overflow. So how does an assembly program differentiate between unsigned and signed data since it's only a sequence of bits? (Through additional memory storage for type information, or through positional information or else?) And could these two flags be used interchangeably?

推荐答案

的区别是什么指令来操作数据,而不是数据本身。现代计算机(自大约1970年)使用一种叫做二进制补码整数数据的再presentation中的加法和减法工作的有符号和无符号数完全相同。

The distinction is in what instructions are used to manipulate the data, not the data itself. Modern computers (since circa 1970) use a representation of integer data called two's-complement in which addition and subtraction work exactly the same on both signed and unsigned numbers.


  • 在重新presentation不同的是给出最显著位间pretation(也称为的符号位的)。对于无符号数该位意味着一个非常大的正数;对于有符号数,这意味着一个非常大的负数(带大绝对值负数)。

  • The difference in representation is the interpretation given to the most significant bit (also called the sign bit). For unsigned numbers that bit means a very large positive number; for signed numbers that means a very large negative number (negative number with a big absolute value).

不同的指令可以使用​​相同的位不同间$ P​​ $ ptations。例如大多数的大机器有符号和无符号乘法指令。用设置为低于指令可能已签名和未签名的味道。

Different instructions may use different interpretations of the same bit. For example most big machines have both signed and unsigned multiply instructions. Machines with a 'set less than' instruction may have both signed and unsigned flavors.

的作者(溢出标志)讲述了一个进位是否翻转结果中的最显著位的符号,使得它是从参数的最显著位不同。如果数字是PTED为无符号间$ P $,溢出标志是无关紧要的,但如果是跨preTED为签署的手段,例如,增加了两个大的正数,结果为阴性。

The OF (overflow flag) tells whether a carry flipped the sign of the most significant bit in the result so that it is different from the most significant bits of the arguments. If numbers are interpreted as unsigned, the overflow flag is irrelevant, but if they are interpreted as signed, OF means, e.g., two large positive numbers were added and the result was negative.

对CF(进位标志)讲述了一个位是否被执行的字完全(例如进位33位或65)。如果数字是PTED为无符号间$ P $,进位标志意味着除了溢出,结果是太大,无法在一台机器字。溢出标志是无关紧要的。

The CF (carry flag) tells whether a bit was carried out of the word entirely (e.g. into bit 33 or bit 65). If numbers are interpreted as unsigned, carry flag means that addition overflowed, and the result is too large to fit in a machine word. The overflow flag is irrelevant.

在回答你的问题是,组装code有从无符号数区分签署几种方式:

The answer to your question is that assembly code has several ways of distinguishing signed from unsigned data:


  • 可能选择使用CF或做符号或无符号的比较。

  • 它可以选择任何符号或无符号乘法和除法指令。

  • 这可能会选择一个符号或无符号右移(签署副本高位;无符号轮换着零)。

这篇关于有关程序集CF(进位)和(溢)标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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