; multiply and accumulate routine for DSP ;macfix(output y,input x, coefficient); .global macfix macfix: ;coefficient is in right place -- 3rd parameter is in r21:r20 ;input x aready in right place -- 2nd parameter is in r22:23 ;input y already in right place -- first parameter is in r25:r24 ;output goes to r25:r24 with ;r25:r24 += r23:r22 * r21:r20 muls r23, r21 ; (signed)ah * (signed)bh add r25, r0 ; only the low byte can affect the result mul r22, r20 ; al * bl add r24, r1 clr r1 adc r25, r1 ; propagate the carry to the hi-byte mulsu r23, r20 ; (signed)ah * bl add r24, r0 adc r25, r1 mulsu r21, r22 ; (signed)bh * al add r24, r0 adc r25, r1 clr r1 ; required for GCC ret