kevj
- 23rd February 2008, 19:19
If I want to keep a particular loop as fast as possible (fewest cycles), does it add more time to reference a value by it's variable name?
For example, do these two code blocks take the same number of cycles to execute....
EXAMPLE 1:
myVar = 273
EXAMPLE 2:
(assuming SomeNum is already defined as a BYTE and loaded with the value "273")
myVar = SomeNum
And more specifically, when loading the registers of a 16-bit timer... let's say I already have the value "%01010101" loaded into a BYTE variable named "HighTimes" and "%11110001" loaded into a BYTE variable named "LowTimes".....
EXAMPLE 1:
TMR1H = %01010101
TMR1L = %11110001
EXAMPLE 2:
TMR1H = HighTimes
TMR1L = LowTimes
Does this second example take longer to execute because it must go look up the value of the variable before the copy to the register?
For example, do these two code blocks take the same number of cycles to execute....
EXAMPLE 1:
myVar = 273
EXAMPLE 2:
(assuming SomeNum is already defined as a BYTE and loaded with the value "273")
myVar = SomeNum
And more specifically, when loading the registers of a 16-bit timer... let's say I already have the value "%01010101" loaded into a BYTE variable named "HighTimes" and "%11110001" loaded into a BYTE variable named "LowTimes".....
EXAMPLE 1:
TMR1H = %01010101
TMR1L = %11110001
EXAMPLE 2:
TMR1H = HighTimes
TMR1L = LowTimes
Does this second example take longer to execute because it must go look up the value of the variable before the copy to the register?