5.18 __multiply_signed_with_unsigned Intrinsic Function

The IAR __multiply_signed_with_unsigned intrinsic function provides access to the mulsu instruction.

Suggested Replacement

There is no MPLAB XC8 equivalent built-in function; however, the instruction can be inserted explicitly using in-line assembly code.

Use in-line assembly to directly write an mulsu instruction.

Caveats

None

Examples

Consider migrating IAR code such as:
int operation(signed char x, unsigned char y)
{
    int result = __multiply_signed_with_unsigned(x, y);
    return result;
}
to MPLAB XC8 code similar to:
#include <xc.h>

int multiply_signed_with_unsigned(signed char x, unsigned char y)
{
  int z;
  __asm__("mulsu %1, %2      \n\t"
          "movw %0, r0       \n\t"
          "clr __zero_reg__  \n\t"
          : "=r" (z)
          : "a" (x), "a" (y));
  return z;
}

int operation(signed char x, unsigned char y)
{
    int result = multiply_signed_with_unsigned(x, y);
    return result;
}

Further Information

See the In-line Assembly section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on adding in-line assembly.