开发者

subtract instruction in processors

Why should a processor implement a subtract开发者_JAVA百科 instruction ? Why cant the compilers change subtraction to 2-s complement additions?


Because if every subtraction had to be two instructions (negate and add) then you'd waste a lot of memory traffic (because code would become larger), cache space (because code would be larger), and instruction decode time (because there would be more instructions to decode), for a tiny gain in CPU simplicity. Totally not worth it.


Addition and subtraction are used enough that it makes sense to build it in. It is a trade off between having more native instructions which require less CPU cycles to faster CPU cycles (more cycles / second).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜