Library calls

There are some library functions used by GCC, during code generation. These use non-standard argument passing schemes, which do not follow the mspgcc ABI. So, do not use them in your assembly code unless you are absolutely sure what is going on. Namely:

Multiplication:

__mul{qi,hi,si}3
__umul{qi,hi,si}3
__umulsi3hw

For devices without a hardware multiplier, multiply routines are called to perform multiplication. If the destination is in HI mode (16 bit) or QI mode (8 bit), the first argument is passed in r10, and the second in r12. The returned value is in r14. In SI mode (32 bit), the first argument is passed in r11:r10, and the second in r13:r12. The result in r14:r15. In both cases the input arguments are clobbered after the function returns.

Division:

__divmod{qi,hi,si}4
__udivmod{qi,hi,si}4

If destination is in HI mode (16 bit) or QI mode (8 bit), the numerator is passed in r12, and the denominator in r10. The result of the calculation r12/r10 is returned with the quotient in r12 and the remainder in r14. Registers r10, r11 and r13 are clobbered.

In SI mode (32 bit), the numerator is passed in r13:r12 and denominator in r11:r10. The quotient is returned in r13:r12, and the remainder in r15:r14. Registers r8, r9, r10, and r11 are cloberred.

All floating point library calls can be used the in the usual way, as these obey the mspgcc ABI rules (when applicable - just help me to force this process :).