Hi Bill, On Fri, Jun 5, 2009 at 9:57 AM, William "Chops" Westfield wrote: > Um. I don't know that I can let that stand. Presumably you're > talking about the rather inefficient avr add sequence: > LDS R0, VAR1 ;2 cycles (4 bytes) > LDS R1, VAR2 ;2 cycles (4 bytes) > ADD R0, R1 ;1 cycle (2 bytes) > STS R0, VAR3 ;2 cycles (4 bytes) > Compared to the PIC sequence: > MOVF VAR1,w ;4 cycles (2 bytes) > ADDWF VAR2,w ;4 cycles (2 bytes) > MOVWF VAR3 ;4 cycles (2 bytes) > Is that about right? > Actually I was more thinking about this: > talking about the rather inefficient avr add sequence: LDS R0, VAR1 ;2 cycles (4 bytes) LDS R1, VAR2 ;2 cycles (4 bytes) ADD R0, R1 ;1 cycle (2 bytes) STS R0, VAR2 ;2 cycles (4 bytes) > Compared to the PIC sequence: MOVF VAR1,w ;4 cycles (2 bytes) ADDWF VAR2,f ;4 cycles (2 bytes) which is like more "cheating" and "unfair" comparison (7 clock cycles vs. 8 clock cycles). What I wanted to point out is that MIPS is not everything. AVR hat on) that if this was time-critical code, then the VARs would > be stored in AVR registers (which are not present on PICs) instead of > RAM (which would make it much faster - probably 2 cycles), and if the > PIC code was going to match the 64k address range of VARn it would > need additional instructions to handle banking and get slower. > That's correct, AVR is a register architecture while PIC is (almost) an accumulator based one. "Almost" as the ALU can put the results back to the RAM location, hence the name of "Working Register" instead of "Accumulator". To be honest in a complex calculation gcc will optimize the use of the AVR's registers (as long as the variable was not marked as volatile) so as an average it is faster than PIC (I would not say that is 4x times faster though, and with a higher power consumption as a trade off). Similar if you are using time critical apps on PIC you can organise variables to be stroed on the same bank or place them on the access RAM so you can dramatically reduce the need of bank switching. Anyway, couple of things I like in AVR: 1. The vector based interrupts 2. Port bit toggling capabilities 3. Extended instruction set (bit even more sophisticated than 18F) 4. Free gcc compiler without any limitations Few things I like on PIC: 1. Very stable device and hard to destruct 2. Easy to get it in low, middle or high volume 3. Wide range of support including appnotes and piclist ;-) 4. MPLAB with MPSIM and debugger support (which has regression test capabilities through stimulus files) Tamas -- http://www.mcuhobby.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist