Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ARM have 16 registers?

Why does ARM have only 16 registers? Is that the ideal number?

Does distance of registers with more registers also increase the processing time/power ?

like image 742
Carbonizer Avatar asked Dec 11 '11 19:12

Carbonizer


People also ask

How many registers are there in ARM?

ARM processors have 37 registers. The registers are arranged in partially overlapping banks. There is a different register bank for each processor mode. The banked registers give rapid context switching for dealing with processor exceptions and privileged operations.

What general-purpose registers are most 16 bit instructions restricted to?

Most 16-bit Thumb instructions can only access R0 to R7. Only a small number of these instructions can access R8-R12, SP, LR, and PC. Registers R0 to R7 are called Lo registers. Registers R8-R12, SP, LR, and PC are called Hi registers.

Why do we only have 32 registers?

Smaller is faster. The desire for speed is the reason that MIPS has 32 registers rather than many more.

Why does x86 have so few registers?

Adding more registers would no longer be x86, so you mean 'creating a new instruction set based on x86 with more registers'. Most compilers would not use these as they can just as well compile to x86 to also target a superset of x86. More registers means more expensive hardware.


1 Answers

As the number of the general-purpose registers becomes smaller, you need to start using the stack for variables. Using the stack requires more instructions, so code size increases. Using the stack also increases the number of memory accesses, which hurts both performance and power usage. The trade off is that to represent more registers you need more bits in your instruction, and you need more room on the chip for the register file, which increases power requirements. You can see how differing register counts affects code size and the frequency of load/store instructions by compiling the same set of code with different numbers of registers. The result of that type of exercise can be seen in table 1 of this paper:

Extendable Instruction Set Computing

Register   Program   Load/Store  
Count      Size      Frequency  

27 100.00 27.90%
16 101.62 30.22%
8 114.76 44.45%

(They used 27 as a base because that is the number of GPRs available on a MIPS processor)

As you can see, there are only marginal improvements in both programs size and the number of load/stores required as you drop the register count down to 16. The real penalties don't kick in until you drop down to 8 registers. I suspect ARM designers felt that 16 registers was a kind of sweet spot when you were looking for the best performance per watt.

like image 53
Bradley McKinley Avatar answered Oct 12 '22 14:10

Bradley McKinley