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
******************************************************Message
Re: [AVR-Chat] More efficient and space saving code
2004-12-10 by John Samperi
Attachments
- No local attachments were found for this message.