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.
Latency for servicing interrupts
Yes assuming that arrayvariable is defined as global data outside of the ISR.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?
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.
Mike Perks