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
DATA SEGMENT A DB 5 DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV AH,00 MOV AL,A L1: DEC A MUL A MOV CL,A CMP CL,01 JNZ L1 MOV AH,4CH INT 21H CODE ENDS END START![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/41/consider-the-following-assembly-language-program-add-5-0-0-l-1128067-1761601987-0.webp)