Hey all I am fairly new with the MSP430 and I have begun using it to do very simple projects and I am trying to keep track of how many cycles I use within my program, and I have a two simple questions that I cannot find the answer for.
How many cycles does it take to run the 'ret' or 'reti' from my program? How many cycles does it take to assign a variable in MSP430 or to call the variable as seen in my "mov.w #COUNT,r13" as seen below? Here is the part of the code that I am using:
COUNT .equ <number> ; <-- Does this take any cycles?
callLoop: call #myDelay ; 2 cycles
sub.w #1,r12 ; 1 cycles
jne callLoop ; 2 cycles
jmp RESET ; 2 cycles
myDelay: mov.w #COUNT,r13 ; 1 <-- Is it only one cycle to run the mov.w?
delayloop: sub.w #1,r13 ; 1 cycles
jne delayloop ; 2 cycles
ret ; ??? No idea what this would be.
r12 has already been assigned a value earlier. Let me know if you need anything else from me.
Best Answer
According to this article,
ret
is actuallymov.w @sp+,pc
, so it only takes the cycles required for indirection, post-increment and assignment to the program counter..equ
is an assembler directive similar to#define
in C and generates no instructions; themov.w #,r
uses a constant substituted by the assembler and therefore incurs no additional cycles.