Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Latency for servicing interrupts
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode
Author Message
mikep



Joined: 24 Sep 2005
Posts: 771
Location: Austin, TX

Posted: 11 January 2009, 18:57 PM    Post subject: Reply with quote

It all depends where it is done.

They are the same if done in Main because the compiler can pre-compute the address of an array element because the address of the array is known at compile time.

If the array is a parameter to a function or subroutine then the compiler has to use "indexed" addressing where it loads (or saves) data based on an index from an address.

If you write the code using a variable for the index then this is also indexed addressing where the compiler has to first load the start address of the array and then "index" down to the specific element.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 11 January 2009, 21:17 PM    Post subject: Reply with quote

Thanks Mike

So am i right in thinking then that

arrayvariable(1) is the same speed as a standard single var, but arrayvariable(variable) would be slightly slower?

Ben
Back to top
mikep



Joined: 24 Sep 2005
Posts: 771
Location: Austin, TX

Posted: 11 January 2009, 22:36 PM    Post subject: Reply with quote

sturgessb wrote:

So am i right in thinking then that

arrayvariable(1) is the same speed as a standard single var, but arrayvariable(variable) would be slightly slower?

Yes assuming that arrayvariable is defined as global data outside of the ISR.

In terms of native code, indexed addressing usually generates one or two extra AVR machine instructions to setup the index register (usually Y or Z). - say 4 clock cycles.

If you asking about whether you should optimize the ISR by loop unrolling or some other method, I would suggest you measure the performance first and only optimize if necessary. If you plan to try optimizing this way I would go straight to AVR assembler language and enclose the code using #asm and #endasm.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode Time synchro. with the server - Timezone/DST with your computer
Goto page Previous  1, 2
Page 2 of 2

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group