Register Mask
The C166 Compiler supports register masks for function prototypes and external function declarations. The register mask specifies which registers are modified by the function. The register mask is used by the compiler to optimize registers used in the code generated.
The following example shows the definition of a register mask:
<[>extern<]> <[>type<]> funcname (<[>args<]>) @mask
The reg_mask is a 16-bit number that specifies the register modified by this function. Each bit in the reg_mask refers to one C16x/ST10 register. The encoding is as follows:
| Bit Position |
|---|
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|
| -- | DPP3 | MDx | R12 | R11 | R10 | R9 | R8 | R7 | R6 | R5 | R4 | R3 | R2 | R1 | DPP0 |
- DPP3 is the DPP3 register used in copy and compare functions for memory images and strings.
- MDx is the MDL, MDH, and MDC register which is used for multiplication and division.
- R1-R12 are the registers R1-R12. R13, R14, and R15 are saved by the called function and the saved contents are never altered for the caller.
- DPP0 is the DPP0 register that is used for far, huge, and xhuge accesses.
Two special values of the register mask specify all register or no registers:
- 0 (zero) specifies that the function uses all registers. This is the default if the function prototype does not specify a register mask.
- 0x8000 specifies that the function uses no registers. This value is useful for functions like exit that never return to the caller.
The C166 Compiler displays the register mask for each function in the assembly listing (generated by the CODE directive) included in the listing file. The register mask (RMASK) is printed at the beginning and at the end of the function.
Note
- Register mask specifications assist the compiler in generating code with calls to external functions or with forward calls to functions. They are only included for backwards compatibility with C166 Version 1 programs and should not be used for new projects.
- Register masks are provided for compatibility with C166 Version 1 programs. Use the REGFILE compiler directive and REGFILE linker directive to enable global register optimization which automatically creates register masks definitions.