In MIPS, what's the difference between signed addition, unsigned addition, signed subtraction and unsigned subtraction?

走远了吗. 提交于 2019-12-23 13:04:22

问题


add rd, rs, rt
addu rd, rs, rt
sub rd, rs, rt
subu rd, rs, rt

In MIPS, what's the difference between signed addition, unsigned addition, signed subtraction and unsigned subtraction? If their results are the same, what's the point to classified as using signed and unsigned methods?


回答1:


The u simply means that they don't trap on overflow.

Quoting from "MIPS32 Architecture For Programmers Volume II":

The term "unsigned" in the instruction name is a misnomer; this operation is 32-bit modulo arithmetic that does not trap on overflow. This instruction is appropriate for unsigned arithmetic, such as address arithmetic, or integer arithmetic environments that ignore overflow, such as C language arithmetic.



来源:https://stackoverflow.com/questions/19544539/in-mips-whats-the-difference-between-signed-addition-unsigned-addition-signe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!