Using milicode routines
The milicode routines contain machine-dependent and performance-critical functions.
All of the fixed-point divide instructions, and some of the multiply instructions, are different for POWER® family and PowerPC®. To allow programs to run on systems based on either architecture, a set of special routines is provided by the operating system. These are called milicode routines and contain machine-dependent and performance-critical functions. Milicode routines are located at fixed addresses in the kernel segment. These routines can be reached by a bla instruction. All milicode routines use the link register.
Note:
- No unnecessary registers are destroyed. Refer to the definition of each milicode routine for register usage information.
- Milicode routines do not alter any floating-point register, count register, or general-purpose registers (GPRs) 10-12. The link register can be saved in a GPR (for example, GPR 10) if the call appears in a leaf procedure that does not use nonvolatile GPRs.
- Milicode routines do not make use of a TOC.
The following milicode routines are available:
Item | Description |
---|---|
__mulh | Calculates the high-order 32 bits of the integer product arg1 * arg2.
|
__mull | Calculates 64 bits of the integer product arg1 * arg2,
returned in two 32-bit registers.
|
__divss | Calculates the 32-bit quotient and 32-bit remainder of signed
integers arg1/arg2. For division by zero and
overflow, the quotient and remainder are undefined and may vary by
implementation.
|
__divus | Calculated the 32-bit quotient and 32-bit remainder of unsigned
integers arg1/arg2. For division by zero and
overflow, the quotient and remainder are undefined and may vary by
implementation.
|
__quoss | Calculates the 32-bit quotient of signed integers arg1/arg2.
For division by zero and overflow, the quotient and remainder are
undefined and may vary by implementation.
|
__quous | Calculates the 32-bit quotient of unsigned integers arg1/arg2.
For division by zero and overflow, the quotient and remainder are
undefined and may vary by implementation.
|
The following example uses the mulh milicode routine in
an assembler program:
li R3, -900
li R4, 50000
bla .__mulh
...
.extern .__mulh