Consider the following assembly language program add 5 0 0 l
Consider the following assembly language program:
add $5, $0, $0
lw $1, 40($6) /* assume Mem[40 + R[$6] == 5 */
loop: addi $1, $1, -1
add $5, $5, $1
add $6, $5, $0
sw $1, 20($6)
bne $1, $0, <loop>
nop
nop
A) Assume that the code is executed in a non pipelined CPU, with each instruction taking 5 clock cycles. What is the total execution time in clock cycles?
B) Assume that the code is executed in our 5 stage pipeline with no forwarding. You will have to stall or insert nops to resolve dependencies. What is the total execution time in clock cycles?
C) Assume that the code is executed in our 5 stage pipeline with forwarding. What is the total execution time in clock cycles?
Solution
The procedure to calculate the execution time (ET) for a piece of AVR assembly code containing single loops require a bit more. You still will need the following information:
Once you have the above information follow the steps below to calculate the execution time:
Steps to calculate ET
Period (T) = 1/Frequency(f)
ET = T * C
![Consider the following assembly language program: add $5, $0, $0 lw $1, 40($6) /* assume Mem[40 + R[$6] == 5 */ loop: addi $1, $1, -1 add $5, $5, $1 add $6, $5, Consider the following assembly language program: add $5, $0, $0 lw $1, 40($6) /* assume Mem[40 + R[$6] == 5 */ loop: addi $1, $1, -1 add $5, $5, $1 add $6, $5,](/WebImages/45/consider-the-following-assembly-language-program-add-5-0-0-l-1143206-1761613661-0.webp)