User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 456,470 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,806 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 365 | Replies: 0
Reply
Join Date: Aug 2008
Location: South Africa
Posts: 4
Reputation: AndreC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AndreC's Avatar
AndreC AndreC is offline Offline
Newbie Poster

Prefetch and MAC instructions

  #1  
Aug 4th, 2008
Hi

I need to do a correlation of 40 samples using a dsPIC30F6014A (@80Mhz) in less than 15us, but found that when I write the correlation in C, it takes way too long (about 40us). I came accross the MAC function in assembly, which (if I can get it going) would be perfect. I am writing the assembly code inline in MikroC.

Unfortunatley I just can't get it to work. I have two main problems:

1) Using the following code, the ACCAL register only becomes 0000 0100, instead of 0001 0100. What's wrong?

asm {
   CLR ACCA

   MOV #0x0004, W4;
   MOV #0x0005, W5;
    
   MAC W4*W5, A
   MOV W4,PORTD
   MOV W5,PORTF
   MOV ACCA, W0
   MOV W0, PORTG
 }
2) The previous code was used mainly because I can't get the following code to work

int Temp1 = 4 absolute 0x0802;    //Declare variable and assign specific location
int Temp2 = 5 absolute 0x0804;    

asm {
  CLR ACCA;  //Clears Accumulator A - not sure if this is necessary ?

  MOV #0x0802,W8;   //Move the variable address values into W8 and W10   
  MOV #0x0804,W10;   
  
  MAC W4*W5, A, [W8], W4, [W10], W5;
  MOV W4,PORTD;
  MOV W5,PORTF;
  MOV ACCA, W0;    //I can't move ACCA directly to PORTG - don't know why ?
  MOV W0, PORTG;
}
The problem seems to be with the MAC insctruction, because the program runs to the end if I comment it out.

Where can I find working examples of prefetch and the MAC instructions. I have looked at everything I can find, but not a single website has a complete example that I can learn from. It is seriously frustrating spending hours on end on what should only be 5 lines of code. Any help will be appreciated!

Oh, and beware of googling MAC...
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Assembly Forum

All times are GMT -4. The time now is 2:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC