C251 User's Guide

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
1R11WR6
(MSB in R6,
LSB in R7)
DR4DR0DR0, DR4
2R7WR4
DR0DR4 
3R6WR2   
4R5WR0   
5R4    
6R3    
7R2    
8R1    
9R0    

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.

DeclarationDescription
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.