MIPS Number of Instructions Executed and Memory Accessed

  • Thread starter Thread starter thchao
  • Start date Start date
  • Tags Tags
    Memory Mips
AI Thread Summary
The discussion focuses on calculating the static and dynamic instruction counts for a given MIPS assembly code. The static instruction count is determined to be 6, while the dynamic instruction count is calculated as 299, accounting for loop iterations. Instruction memory is accessed 299 times, and data memory is accessed 99 times during execution. The execution time is computed to be approximately 2.99 milliseconds based on a CPI of 1 and a clock rate of 100 KHz. Clarifications on the execution of the BNE instruction and the specific MIPS processor are also mentioned.
thchao
Messages
2
Reaction score
0

Homework Statement


The number of instructions a program has is the static instruction count. The number of instructions actually executed (e.g. due to some instructions being repeated, as in a loop) is called the dynamic instruction count. Consider the following code:
li $t0, 99
li $t1, 44
loop: addi $t0, $t0, -1
lw $t1, 0($t1)
bne $t0, $zero, loop
add $v0, $t0, $zero

a. What is the static instruction count of this code? What is the dynamic instruction count? (Assume any pseudoinstructions are counted as 1 instruction).
b. How many times is the instruction memory accessed? How many times is the data memory accessed?
c. Assuming this runs on a single cycle processor (with CPI = 1) running at 100 KHz, how long will the code take to execute?

Homework Equations


[/B]
Execution Time = (CPI * IC) / Clock Rate

The Attempt at a Solution



a. Static Instruction Count: 6 (Since there are only 6 instructions in the code.)
Dynamic Instruction Count: (99 * 3) - 1 + 3 = 299 (The two li instructions and the add instruction only executed once. The loop itself executes 99 times but bne instructions executes only 98 times since at the 99th iteration, $t0 = 0 and bne instruction won't executed.)

b. Instruction Memory Accessed: 299 (Number of times program counter updated)
Data Memory Accessed: 99 (Number of times lw or load instruction was executed)

c. Given CPI = 1, IC = 299 (from part a), Clock Rate = 100000 (Converted KHz to Hz)
Execution Time = (1 * 299) / 100000 = 2.99 x 10-3 milliseconds

I am not sure if I calculated the Dynamic Instruction Count correctly and if the Instruction Memory Accessed is correct or not. Any input would greatly appreicated.
 
Last edited:
Physics news on Phys.org
thchao said:
... but bne instructions executes only 98 times since at the 99th iteration, $t0 = 0 and bne instruction won't executed.)
BNE executes every time. The duration may vary, but I think here you are not asked to consider that.

Perhaps you could say what processor this is, so that we can look up details.
 
It's the MIPS processor.
 

Similar threads

Replies
2
Views
2K
Replies
3
Views
2K
Replies
4
Views
5K
Replies
2
Views
5K
Replies
4
Views
6K
Replies
1
Views
2K
Replies
7
Views
3K
Back
Top