RE: Question: regarding mac instructions in CodeWarrior

"Seymour David" <[email protected]> Wed, 2 Apr 2008 15:24:44 -0700
Newsgroups gmane.comp.hardware.motorola.microcontrollers.coldfire
Message-ID <FE151544B54DB0428FFA9AE99C27A12101DA9AAB@az33exm22.fsl.freescale.net>
Hi Andy,

Best to post ColdFire architecture and CodeWarrior questions to the
Freescale Forum's user group.

http://forums.freescale.com/freescale/board?board.id=CFCOMM 

 

Here is some assembly code using MAC instructions for CodeWarrior.  I'm
not the owner...just had a copy to share.  Hope it helps.

 

            movea.l            iir_arg_ptr,A0

            move.l  iir_input_offset(A0),A5 ; pntr to input data

            lea.l      iir_buffer_offset(A0),A3; addr. of buffer

            move.l  A3,A2                          ; copy to A2 for
movem command

            lea.l      iir_coef_offset(A0),A4  ; addr of coef.start


            move.l  #0x00000080,MACSR            ; load MACSR for
Sat|signed|Integer|round

 

            move.w  (A5),D7                                 ; load x(n)
into D7

 

            ; A3 points to Data_In, A1 points to the first pair of
packed

            ; numerator coefficients, A0 points to bottom of numd
buffer.

            

            ; Now we start the filter.  For an Nth order filter, we have
N+1 numerator terms.

            clr.l       D0

            move.l  D0,ACC                                  ; clear the
acc

 

            move.l  (A4)+,D5                     ; load N3,N2 into D5,
A1 points to N1,N0

            move.l  (A3)+,D1                     ; load x(n-3) into D1
(part of a trick)

            mac.w  D1.l,D5.u,(A3)+,D0     ; x(n-3)*N3 -> acc, x(n-2)
into D0 (more trick)

            mac.w  D0.l,D5.l,(A4)+,D6      ; Acc+x(n-2)*N2 -> acc, N1,0
into D6

            move.l  (A3)+,D1                     ; move x(n-1) into D1

            mac.w  D1.l,D6.u                     ; Acc+x(n-1)*N1 -> acc.

            move.l  D7,D2                          ; x(n) into D2

            mac.w  D2.l,D6.l                      ; acc+x(n)*N0 -> acc.

            movem.l           D0-D2,(A2)                 ; and move the
data back, shifted down.

            move.l  ACC,D7                                  ; move the
acc into D7

            move.b iir_num_sf_offset(A0),D6; get the num scale factor
[ByteN]

            andi.l    #0x000000FF,D6                    ; mask off ByteN
(to make sure)

            asr.l      D6,D7                          ; shift by
difference between num and den

            clr.l       D6                               ; clear so we
can add 0 + CCR(X)

            addx.l   D6,D7                          ; add carry bit

            move.l  D7,ACC                                  ; move back
to acc.

 

Regards, 

David 

 

David E Seymour

Come to FTF 2008 June 16th through the 19th in Orlando

http://www.freescale.com/ftf 

________________________________

From: [email protected] [mailto:[email protected]]
On Behalf Of Andy Gabler
Sent: Wednesday, April 02, 2008 4:15 PM
To: Seymour David
Subject: [ColdFire] Question: regarding mac instructions in CodeWarrior

 

Greetings all,

I am working on writing an FIR filter for the MCF5275 and I am
attempting to utilize the emac. I have obtained the DSP library from
Freescale (DSPLIPUMSW); however, when I compile the the FIR filter code
or when I write my own "mac" instructions like "asm("mac.w %d0.l, %d1.l,
<<, %ACC0") I get the following error: 

Error   : C:\DOCUME~1\rr\LOCALS~1\Temp\ccQ9aaaa.s : Assembler messages:

Error   : syntax error -- statement `mac.w %d0.l,%d1.l,<<,%ACC0' ignored
ccQ9aaaa.s line 130   

all the other assembly I have written it compiles but it gets stuck on
each mac instruction.  

I am using the CodeWarrior IDE 5.0.9 to do the compilation.

If anyone has suggestions/ideas of how to make this work I would greatly
appreciate them.

Thanks,

andy


[email protected] Send a post to the list.
[email protected] Join the list. [email protected]
Join the list in digest mode. [email protected] Leave the
list.