Technical information

Functions Written from Scratch A-1
Appendix A
Functions Written from Scratch
A.1 Optimized Ported Version of RXDEMOD
RXDEMOD
move.l #BPF_OUT,r3 ; Init. pointer to demod inputs
move.l #RXCB2A,r2 ; Init. pointer to demod outputs
move.l #MOD_TBL,r0 ; Load address of carrier freq.
; table.
move.l #SIN_TBL,r5 ; keep SIN_TBL in r5
move.l #DPHASE,r4 ; and DPHASE in r4
move.w x:CDP,d ; load CDP and keep it in d
do #12,end_rx_demod ; Loop 12 times
moveu.w #$80ff,m01 ; r1 is set to mod 256 mode of
; addressing
tfr d,a ; Load CDP from d
add.w x:(r4),a
move.w #$0080,y0 ; Load constant for DPHASE >> 8
move.w a1,x:(r4) ; Save DPHASE
; Note : if DPHASE overflows then
; the modulo value is stored
; DPHASE is kept in r4
; REM & OFFSET
mpy a1,y0,a ; rem = DPHASE%256 in a0
; and offset = DPHASE>>8 in a1
move.w a0,y1 ; Save the fractional part
bfclr #$ff00,a ; Truncate offset to 8 LS bits
; which is also a modulo 256
; calculation
lsr.w y1 ; shift to get into 1.15 format
; SINPHI & COSPHI
moveu.w a1,r1
adda r5,r1 ; Load the address register with the
; correct location in the 256 point
; sine table.
moveu.w #$40-1,n ; Load offset register
move.w x:(r1)+,a ; sine1 = SIN_TBL(offset)
move.w x:(r1)+n,b ; sine2 = SIN_TBL(offset+1)
sub a,b ; sine2-sine1 in y0
move.w b1,y0 ;
macr y1,y0,a x:(r1)+,b ; sinphi = sine1+(sine2-sine1)*rem
; cos1 = SIN_TBL(offset+$40)
move.w x:(r1)+,c ; cos2= SIN_TBL(offset+$40+1)
sub b,c ; cos2-cos1 in y0
moveu.w #11,m01 ; Set r0 to mod 12 addressing mode
; -SIN & COS
move.w c1,y0
macr y1,y0,b x:(r0)+,y0 ; cosphi = cos1+(cos2-cos1)*rem
; Get cosw from memory
moveu.w x:mod_tbl_offset,n ; Load offset to MOD_TBL
move.w b,c ; Saturate the output
mpyr a1,y0,b x:(r0)+n,y1 ; sinphi*cosw
; Get -sinw from memory
macr c1,y1,b ;-SIN = -sinw*cosphi+cosw*sinphi
tfr b,x0 Save -SIN
move.w y0,n
move.w y1,y0 ; Get -sinw
move.w n,y1 ; Get cosw
mpy c1,y1,b x:(r3)+,y1 ; cosw*cosphi in b
; Get X
macr -a1,y0,b ; COS = sinw*sinphi+cosw*cosphi
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...