Hey Les, Thanks for pointing out. Its surely a shorter code from John...hahaha... Thanks again. Good job John !! Regards, Andrew Les Grant <lesgrant@grantronics.com.au> wrote: Hi John, Last time I looked, LDS and STS were 2 words each so the original routine was 21 words... ;-) And your new routine is only 10 words so it looks like a worthwhile saving... :-) Regards, Les. On 10 Dec 2004 at 15:43, John Samperi wrote: > > At 06:52 PM 9/12/04 -0800, you wrote: > > Hi guys, Is there anyone who can make this code more efficient? > > Use 2 of the index registers as pointers with auto increment. > May not save much as your routine is only 10 words long. > > TSM_Curr2Ptr: > ldi counter,5 ;a register such as r17 > > ldi xl,low(TSM_Data_Curr) ;Setup origin > ldi xl,high(TSM_Data_Curr) > > ldi yl,low(TSM_Data_Ptr) ;Setup destination > ldi yl,high(TSM_Data_Ptr) > > lp: > ld TSM_Temp, x+ ;Get data and increment x > st y+, TSM_Temp ;Store data and increment > dec counter > brne lp > ret > > Actually it's not shorter :-((.... but it would be shorter if you had lots > more > data to move. Perhaps there is a genius out there with a better solution :-)) > > >TSM_Curr2Ptr: > > lds TSM_Temp, TSM_Data_Curr > > sts TSM_Data_Ptr, TSM_Temp > > lds TSM_Temp, TSM_Data_Curr+1 > > sts TSM_Data_Ptr+1, TSM_Temp > > lds TSM_Temp, TSM_Data_Curr+2 > > sts TSM_Data_Ptr+2, TSM_Temp > > lds TSM_Temp, TSM_Data_Curr+3 > > sts TSM_Data_Ptr+3, TSM_Temp > > lds TSM_Temp, TSM_Data_Curr+4 > > sts TSM_Data_Ptr+4, TSM_Temp > > ret ; Exit Regards, Andrew > > > Regards > > John Samperi > > ****************************************************** > Ampertronics Pty. Ltd. > 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA > Tel. (02) 9674-6495 Fax (02) 9674-8745 > Email: samperi@ampertronics.com.au > Website http://www.ampertronics.com.au > * Electronic Design * Custom Products * Contract Assembly > ****************************************************** > > > > > > Yahoo! Groups Links > > > > > > > ------------------------------------------------------------- Les Grant. VK2KYJ. Phone: 02 9896 7150 Fax: 02 9896 7153 Grantronics Pty Ltd Int'l: +612 9896 7150, +612 9896 7153 ABN 46 070 123 643 PO Box 275, Wentworthville. NSW. 2145. Australia. http://www.grantronics.com.au mailto:info@grantronics.com.au Microcontroller Hardware and Software development: Atmel AVR 8051 derivatives, 80C196 family, C, ASM, Digital and analogue ------------------------------------------------------------- Australian distributor for: o Dunfield Development Systems low cost development tools o ImageCraft AVR and Motorola Windows-hosted C compilers o ELNEC Device Programmers (E)EPROMs, Flash, Micros, PLDs o CAN-BUS Hardware and Software from LAWICEL o Logical Systems Programming, Prototyping & Production Adaptors ------------------------------------------------------------- Yahoo! Groups SponsorADVERTISEMENT --------------------------------- Yahoo! Groups Links To visit your group on the web, go to: http://groups.yahoo.com/group/AVR-Chat/ To unsubscribe from this group, send an email to: AVR-Chat-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. --------------------------------- Do you Yahoo!? The all-new My Yahoo! � Get yours free!
Message
Re: [AVR-Chat] More efficient and space saving code
2004-12-16 by Andrew Lim
Attachments
- No local attachments were found for this message.