If I was given Assembly code like the below, how could I determine how many clock cycles it will take to execute?
ldi r20, 250
loop: inc r20
brne loop
nop
In the datasheet, all the instructions take up 16 bits (1 instruction word).
Attempting it myself, I get 14 as the answer. Since ldi r20, 250
is called once (1 cycle), then the loop is called 6 times before overflow to zero occurs (6x2=12 cycles). And finally at the end, nop
takes 1 cycle. In total that is 14 cycles.
However, the answer is apparently 19 cycles. Would anyone be able to tell me what I have done wrong?