next up previous contents index
Next: 3.14.2 Registers usage Up: 3.14 Interfacing with Assembler Previous: 3.14 Interfacing with Assembler   Contents   Index


3.14.1 Global Registers used for Parameter Passing

The compiler always uses the global registers DPL, DPH, B and ACC to pass the first (non-bit) parameter to a function, and also to pass the return value of function; according to the following scheme: one byte return value in DPL, two byte value in DPL (LSB) and DPH (MSB). three byte values (generic pointers) in DPH, DPL and B, and four byte values in DPH, DPL, B and ACC. Generic pointers contain type of accessed memory in B: 0x00 - xdata/far, 0x40 - idata/near - , 0x60 - pdata, 0x80 - code.

The second parameter onwards is either allocated on the stack (for reentrant routines or if --stack-auto is used) or in data/xdata memory (depending on the memory model).

Bit parameters are passed in a virtual register called 'bits' in bit-addressable space for reentrant functions or allocated directly in bit memory otherwise.

Functions (with two or more parameters or bit parameters) that are called through function pointers must therefor be reentrant so the compiler knows how to pass the parameters.


next up previous contents index
Next: 3.14.2 Registers usage Up: 3.14 Interfacing with Assembler Previous: 3.14 Interfacing with Assembler   Contents   Index
2008-12-05