28.2.90 __builtin_msc

Architecture

dsPIC33C/E/F, dsPIC30

Description

Computes a x b and subtracts from accumulator; also prefetches data ready for a future MAC operation.

xptr may be null to signify no X prefetch to be performed, in which case the values of xincr and xval are ignored, but required.

yptr may be null to signify no Y prefetch to be performed, in which case the values of yincr and yval are ignored, but required.

xval and yval nominate the address of a C variable where the prefetched value will be stored.

xincr and yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an integer value.

If AWB is non null, the other accumulator will be written back into the referenced variable.

For example:

 volatile register int16_t result asm("A");
 int16_t *xmemory;
 int16_t *ymemory;
 int16_t xVal, yVal;

 result = __builtin_msc(result, xVal, yVal,
                     &xmemory, &xVal, 2,
                     &ymemory, &yVal, 2, 0, 0);

might generate:

 msc w4*w5, A, [w8]+=2, w4, [w10]+=2, w5

Prototype

int16_t __builtin_msc(int16_t Accum, int16_t a, int16_t b, 
  int16_t **xptr, int *xval, int xincr, 
  int16_t **yptr, int *yval, int yincr, int *AWB,
  int16_t AWB_accum);

Arguments

Accum – Accumulator to subtract.

a – Integer multiplicand.

b – Integer multiplier.

xptr – Integer pointer to pointer to x prefetch.

xval – Integer pointer to value of x prefetch.

xincr – Integer increment value of x prefetch.

yptr – Integer pointer to pointer to y prefetch.

yval – Integer pointer to value of y prefetch.

yincr – Integer increment value of y prefetch.

AWB – Accumulator write back location.

AWB_accum – Accumulator to write back.

Return Value

Returns the value of accumulator minus the result of a x b.

Machine Instruction

msc

Error Messages

An error message will be displayed if:

  • the result is not an accumulator register
  • Accum is not an accumulator register
  • xval is a null value but xptr is not null
  • yval is a null value but yptr is not null
  • AWB_accum is not an accumulator register and AWB is not null