View Single Post
  #5   Spotlight this post!  
Unread 21-01-2007, 23:50
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: CPU Load in FRC RC

Quote:
Originally Posted by Don Rotolo View Post
...My question has to do with the relative load on the CPU for the various programmatical operations that can be performed...
The PIC processor is designed so that every operation takes one clock cycle. Branch instructions are an exception; they take two. But the architecture of the PIC CPU is unusual in that read/write data and program code are not in the same memory space, and the ALU has some odd restrictions on where the results end up. This means that what looks like a simple operation in C might end up being a simple operation on the PIC -- or it might end up being a page of assembly language to implement. Floating point arithmetic is particularly costly, as the PIC ALU doesn't support floating point in hardware.

If you're interested in the relative cost in program space (which translates almost directly to execution time) for various operations, I suggest you try compiling a program which uses those operations and then inspect the listing file to see how the compiler translates them into PIC assembly language.