开发者

subtract instruction in processors

开发者 https://www.devze.com 2023-02-21 18:45 出处:网络
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 (

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

精彩评论

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