Hello Johan,
If my understanding of your proposal is correct, there appears to be some advantage in arranging so that the sign of the coefficient be placed in a separate register prior to DFT processing. This should increase the (unsigned) resolution of the coefficient from 7-bits to 8-bits.
The following code would seem to achieve what you describe -
;**************************************************************
; ACCUMULATE SCALED SAMPLE VALUE TO 24-BIT SUM
; On entry,
; ACC = sample value (8-bit unsigned),
; X = Phase coefficient (positive 8-bit value),
; PH_SIGN register (MSB) contains the sign of the coefficient.
; On exit, 24-bit value of SUM is updated.
; RAM registers PH_SIGN and SUM must reside in page zero.
PROCSAMP: MUL
BRCLR 7,PH_SIGN,PS1 ; Branch if positive sign
; Subtract scaled result from 24-bit sum
PSHA
PSHX
LDA SUM+2
SUB 2,SP
STA SUM+2
LDA SUM+1
SBC 1,SP
STA SUM+1
BCC *+4 ; Skip next if no carry
DEC SUM
AIS #2 ; Adjust stack pointer
RTS
PS1: ; Add scaled result to 24-bit sum
ADD SUM+2
STA SUM+2
TXA
ADC SUM+1
STA SUM+1
BCC *+4 ; Skip next if no carry
INC SUM
RTS
The processing of the routine should take 43 cycles for a positive coefficient, and 56 cycles for a negative coefficient. The question is can you live with this sort of sample processing period?
I also looked at the possibility, in the case of a negative coefficient, of negating the result of the multiplication, and then adding to SUM - this would appear to save only two cycles (assuming my coding is correct), and also quite a few bytes of code.
Regards,
Mac
Message Edited by bigmac on
2007-06-17 02:02 AM