C166 User's Guide

Register Usage

Assembler functions may destroy the contents of R1-R12, PSW, MDL, MDH, MDC, and DPP0. When invoking a C function from assembly, assume that these registers are destroyed.

When using the MAC directive the compiler uses in addition the MAC registers MSW, MAL, MAH, MRW, and IDX0. When code is generated with the MAC directive, these registers are used by C functions (in addition to the register listed above). When invoking a C function form assembly you need therefore to assume that these registers are destroyed too.

The following registers have special meaning and must be preserved by the assembler subroutine.

RegisterDescription
R0R0 is the user stack pointer. At the end of the assembler subroutine the value of R0 must be the same as at the start of the routine.
R13This register may be used but its contents must be saved (on entry) and restored (before returning).
R14This register may be used but its contents must be saved (on entry) and restored (before returning).
R15This register may be used but its contents must be saved (on entry) and restored (before returning).
DPP1This DPP register may not be modified by assembler subroutines. It contains the memory class page and may be used in an interrupt service routine that interrupts the assembler subroutine.
DPP2This DPP register may not be modified by assembler subroutines. It contains the memory class page and may be used in an interrupt service routine that interrupts the assembler subroutine.
DPP3If DPP3 is modified in the assembler subroutine, it must be reset to 3 (SYSTEM PAGE) before returning.

Note

  • DPP0 is used only when the MOD167 C166 Compiler directive is not specified.
  • If your assembler programs alter DPP0, the DPPUSE L166 Linker directive may not be used to assign DPP0 to the near memory area.
  • If your assembler programs alter DPP0 or DPP3, the NODPPSAVE C166 Compiler directive may not be used to bypass saving and restoring DPP0 and DPP3 in interrupts.