segher wrote:

Yes, something like that. It saves instructions because the correction

it has to do at the end is always the same, not dependent on the sign

bit of things; so a) it does not have to calculate with the sign bits, and

b) some expressions can be combined in the end.

The 96-bit result exists in hi:mi:lo

Even easier of course is to use the MACCUS instruction, which

unfortunately does not exist ;-)

ASM-master segher, I might need some helt with negative coeffs.

For positive coeffs, you can do it like this, and with only one coef. A as in this example, the Offset Ohi:Omi can be pre-negated and replace the zero's in the lmul avoiding the lsub in the end.

Insignal: Yhi:Ylo

Coeff: A

Result: hi:mi:lo

**Code:**

POS:

lmul Ohi,Omi,A,offset,zero,zero // Calculate the offset

POSloop:

add Yhi,Yhi,offset //add offset to in-signal

lmul carry, lo, Ylo, A, zero, zero

lmul hi, mi, Yhi, A, zero, carry

//Calc 2-comp. value by subtracting the offset.

lsub borrow,hi,hi,Ohi,zero

lsub s0,mi,mi,Omi,borrow

sub lo,lo,borrow

But what about the negative case ? Can I avoid the negate at the end.

**Code:**

NEG:

lmul Ohi,Omi,A,offset,zero,zero

NEGloop:

add Yhi,Yhi,offset //add offset to in-signal

lmul carry, lo, Ylo, A, zero, zero

lmul hi, mi, Yhi, A, zero, carry

//Calc 2-comp.

lsub borrow,hi,Ohi,hi,zero

lsub borrow,mi,Omi,mi,borrow

sub lo,lo,borrow

//negate hi:mi:lo

not hi,hi

not mi,mi

neg lo,lo