Keil Logo

Passing in Registers

The C251 Compiler uses the registers R11 and R0-R7 for parameter passing. A maximum of 9 parameters may be passed in registers. All other parameters are passed using fixed memory locations or the 251 hardware stack (depending on the function reentrant / static attribute).

The following table lists which registers are used for passing parameters.

Allocation
Order
char,
1-byte ptr
int,
2-byte ptr
long, float
4-byte ptr
double
1 R11 WR6
(MSB in R6,
LSB in R7)
DR4 DR0 DR0, DR4
2 R7 WR4
DR0 DR4  
3 R6 WR2      
4 R5 WR0      
5 R4        
6 R3        
7 R2        
8 R1        
9 R0        

For parameter passing to C51 functions, 3 byte pointers are used; 3 byte pointers are passed in the registers R1/R2/R3. Refer to PARM51 or PARM251 for more information.

C251 allocates registers in the order R11, R7, R6, R5, R4, R3, R2, R1, and R0. If a register is already in use for a parameter variable, C251 continues down the list until a free register is found.

The following examples clarify how registers are selected for parameter passing.

Declaration Description
func1 (
int a)
The first and only argument, a, is passed in register WR6.
func2 (
int b,
int c,
int far *d)
The first argument, b, is passed in register WR6. The second argument, c, is passed in register WR4. The third argument, d, is passed in register DR0.
func3 (
long e,
long f
long g)
The first argument, e, is passed in register DR4. The second argument, f, is passed in register DR0. The third argument, g, cannot be located in registers since those available for a type of long are already used by other arguments. This parameter is passed using fixed memory locations or the 251 hardware stack.
func4 (
char h
float i)
The first argument, h, is passed in register R11. The second parameter, i, is passed in register DR4.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.