如何做ADD / SUB符号或无符号整数是否正确? [英] How to do ADD/SUB signed or unsigned integer correctly?

查看:576
本文介绍了如何做ADD / SUB符号或无符号整数是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有基于ARM的添加指令,它对于签署和<$ C $工作C> unsigned int类型?一些状态标志应该是不同的,当用取值后缀指定的指令,对不对?如设置溢出( V )标志。我想知道有没有ADD / SUB的另一个版本来处理整数之一。

I saw there is an ADD instruction on ARM, does it work for both signed and unsigned int? Some status flags should be different when the instruction is specified with S suffix, right? Such as setting overflow (V) flag. I am wondering is there another version of ADD/SUB to handle one of the integer.

推荐答案

二进制补码表示有符号和无符号除了没有区别。在S位决定任何标志是否修改或不修改IF,然后再进行的是无符号的溢/借贷和v是符号溢出/借。这是武器的所有文档描述。

Twos complement means there is no difference between signed and unsigned addition. The s bit determines whether any flags are modified or not IF modified, then carry is the unsigned overflow/borrow and v is the signed overflow/borrow. This is all described in ARMs documentation.

这篇关于如何做ADD / SUB符号或无符号整数是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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