You must remember that the PIC18 multiplier only works with unsigned bytes. Normally you would do the following:OK! I can do that...but what would be the problem or the difficulty by storing those coefficients as they are and having only one mult_accum routine?
Do you mean the output will have to be sign tested first then a flag will indicate wheter it positve or negative and if negative then that value will be converted into its 2s complement, right? Lemme know if I got that right please...
1) Test 1st operand. If it is negative, 2s complement it *and remember it was negative*.
2) Test 2nd operand. 2s complement if necessary, and remember
3) Multiply
4) if either oper1 or oper2 was negative (but not both), 2s complement the result.
So you have at most 3 2s complement operations to perform with each multiplication! This consumes an extra 2+n instruction cycles per multiplication, where n is the number of bytes of the operand (or result).
I am suggesting that you keep your numbers positive, eliminating the need for the extra 2s complements, and use flags to keep track of +/-. You will still need to test signs and figure the sign of the result, but you will save time overall.
You can still have one mulacc routine. Just have it check the flags and automatically decide to add or subtract the unsigned values. Remember that the output of mulacc may be a signed negative number! You will still need to complement this and set a flag for future multiplies (but keep the accumulator signed, as you'll need it for future add/subs.
BTW, this is one good example of where asm excels over C. You can fine-tune your math for the fastest speed possible *for a particular application*. You don't have that option when writing something like result+=a*b in C.