<< Click to Display Table of Contents >> Direct Access of the 'mach' and 'macl' Registers |
The eTPU registers MACH and MACL are used during MDU operations (multiply/divide) and contain the results upon operation completion. By default, the ETEC standard header files does not expose these registers to the user. Why? Because if they are not in use the compiler/optimizer will use these registers under the hood for temporaries, or to hold local variables. Exposing these variables could in some cases limit the ability of the compiler to generate optimal code. However, there are times when the user might want direct access to these registers, for example to check for 24-bit overflow of a multiply operation. Code for this might look like:
unsigned int a, b, c;
// ...
{
register _MACH mach; // same as "register_mach mach;"
c = a * b;
if (mach != 0)
{
// perform overflow logic
}
}