0

In 8051 memory bank (00h to 1Fh), 8051 provide 32 registers as 8 registers(R0 t0 R7) to each of 4 banks. Why these registers are not given as R0 to R31?

Thanks in Advance..

2 Answers2

4

Many instruction opcodes are only 8 bits long; if all 32 registers were accessible in one of these instructions then there would be only 3 bits left to encode the instruction length and the operation. Similarly, two byte instructions often use the second byte to encode a full 8-bit operand (eg., an address), and have effectively the same constraint.

In many instances it is possible to refer to the register you need by its absolute address, using a longer instruction, but if you will access it frequently then it may be better to change the active bank so that you can use more short opcodes.

sh1
  • 4,324
  • 17
  • 30
  • this is similar to x86 in the early days because some instructions are only encoded by 1 or 2 bytes. Using larger register space would often need longer encoding for instructions since 3 or 4 bits won't be enough for the basic instruction set – phuclv Oct 16 '13 at 06:16
2

As far as I remember you can access only 8 of those register at a time. To access one of the other groups you need to switch the bank. I guess it has something to do with a instruction operand being only 3 bits long (and not 5 bits).

Caladan
  • 1,471
  • 11
  • 13