0% found this document useful (0 votes)
29 views5 pages

Lab-9-Program Analysis

Uploaded by

f20221259
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views5 pages

Lab-9-Program Analysis

Uploaded by

f20221259
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab.

Assignment-9

Computer Architecture (CS F342)


Semester-I, 2024-25
Department of Computer Science and Information Systems (CSIS)
BITS-Pilani, K K Birla Goa Campus, Goa, India.

Due date: Oct 22, 2024: 10 AM Marks: 20

1. Download the CA_Lab9_mipsProgramAnalysis_Template.zip. Three test files are: asm_test1.s,


asm_test2.s, asm_test3.s, asm_test4.s. Perform following analysis using file mipsProgramAnalysis.cpp.
The CPP program takes any assembly program written using 32-bit MIPS’s ISA as an input and prints the
number of valid instructions and type of instructions, number of jumps and types of jumps (forward and
backward), number of register used and display the registers, number of RAW hazards (window size one)
and prints the dependent instructions. All the modules available in the template file have to be used.

Module Marks
verifyInstr_setType() 9
countRegister() 5
checkDependency() 5
countLabels() 1

The expected outputs are:

File Name: .\asm_test1.s


-----------------TOTAL INSTRUCTIONS----------------------------
addi $s0, $zero, 4 ------ I Type
addi $s1, $zero, 10 ------ I Type
addi $s2, $zero, 12 ------ I Type
addi $t1, $zero, 0 ------ I Type
sw $s3, myArray($t3) ------ I Type
addi $t1, $t1, 4 ------ I Type
sw $s4, myArray($t4) ------ I Type
addi $t2, $t1, 4 ------ I Type
sw $s5, myArray($t5) ------ I Type
addi $t0, $zero, 0 ------ I Type
beq $t6, 12, exit ------ I Type
lw $t7, myArray($a1) ------ I Type
addi $t0, $t0, 4 ------ I Type
li $v1, 1 ------ Others
move $a0, $t6 ------ Others
li $v0, 4 ------ Others
j while ------ J Type
li $s7, 10 ------ Others
---------------------------------------------------------------
Total Lines w/o Comments = 33
Total Valid Instructions = 18
Backward Loops/JUMP = 1
Forward LOOPS/JUMP = 0
---------------------------------------------------------------

---------------------------------------------------------------
BACKWARD LABEL FORWARD LABEL
while -------
---------------------------------------------------------------

---------------------------------------------------------------
Names of Register used = zero v0 v1 a0 t0 t1 t2 t6 t7 s0 s1 s2 s3 s4 s5 s7
Total number of registers = 16
---------------------------------------------------------------

---------------------------------------------------------------
Total RAW Dependency = 5
---------------------------------------------------------------

--------------------DEPENDENT INSTRUCTIONS---------------------
addi $t1, $zero, 0 ---> addi $t1, $t1, 4
addi $t1, $zero, 0 ---> addi $t2, $t1, 4
addi $t1, $t1, 4 ---> addi $t2, $t1, 4
addi $t0, $zero, 0 ---> addi $t0, $t0, 4
beq $t6, 12, exit ---> move $a0, $t6
---------------------------------------------------------------

File Name: .\asm_test2.s


-----------------TOTAL INSTRUCTIONS----------------------------
addi $s0, $zero, 4 ------ I Type
addi $s1, $zero, 10 ------ I Type
addi $s2, $zero, 12 ------ I Type
addi $t0, $zero, 0 ------ I Type
sw $s0, myArray($t1) ------ I Type
addi $t4, $t0, 4 ------ I Type
sw $s1, myArray($t2) ------ I Type
addi $t5, $t0, 4 ------ I Type
sw $s2, myArray($t3) ------ I Type
lw $t6, myArray($zero) ------ I Type
li $v0, 1 ------ Others
addi $a0, $t6, 0 ------ I Type
li $v1, 10 ------ Others
---------------------------------------------------------------
Total Lines w/o Comments = 22
Total Valid Instructions = 13
Backward Loops/JUMP = 0
Forward LOOPS/JUMP = 0
---------------------------------------------------------------

---------------------------------------------------------------
BACKWARD LABEL FORWARD LABEL
---------------------------------------------------------------

---------------------------------------------------------------
Names of Register used = zero v0 v1 a0 t0 t4 t5 t6 s0 s1 s2
Total number of registers = 11
---------------------------------------------------------------

---------------------------------------------------------------
Total RAW Dependency = 3
---------------------------------------------------------------

--------------------DEPENDENT INSTRUCTIONS---------------------
addi $t0, $zero, 0 ---> addi $t4, $t0, 4
addi $t0, $zero, 0 ---> addi $t5, $t0, 4
lw $t6, myArray($zero) ---> addi $a0, $t6, 0
---------------------------------------------------------------

File Name: .\asm_test3.s


-----------------TOTAL INSTRUCTIONS----------------------------
addi $t0, $zero, 0 ------ I Type
jal printNumber1 ------ J Type
addi $t2, $t1, 1 ------ I Type
jal printNumber2 ------ J Type
addi $t3, $t2, 1 ------ I Type
j while ------ J Type
li $v1, 1 ------ Others
add $a1, $t0, $zero ------ R Type
li $v0, 4 ------ Others
la $a0, space ------ Others
jr $ra ------ R Type
li $s0, 1 ------ Others
add $s3, $t0, $zero ------ R Type
li $s1, 10 ------ Others
la $s2, space ------ Others
jr $ra ------ R Type
---------------------------------------------------------------
Total Lines w/o Comments = 31
Total Valid Instructions = 16
Backward Loops/JUMP = 1
Forward LOOPS/JUMP = 2
---------------------------------------------------------------

---------------------------------------------------------------
BACKWARD LABEL FORWARD LABEL
while printNumber1
------- printNumber2
---------------------------------------------------------------

---------------------------------------------------------------
Names of Register used = zero v0 v1 a0 a1 t0 t1 t2 t3 s0 s1 s2 s3 ra
Total number of registers = 14
---------------------------------------------------------------

---------------------------------------------------------------
Total RAW Dependency = 3
---------------------------------------------------------------

--------------------DEPENDENT INSTRUCTIONS---------------------
addi $t0, $zero, 0 ---> add $a1, $t0, $zero
addi $t0, $zero, 0 ---> add $s3, $t0, $zero
addi $t2, $t1, 1 ---> addi $t3, $t2, 1

File Name: .\asm_test4.s


-----------------TOTAL INSTRUCTIONS----------------------------
addi $t0, $t0, 0 ------ I Type
beq $t1, 12, exit ------ I Type
lw $t6, myArray($t2) ------ I Type
addi $t3, $t0, 4 ------ I Type
li $v0, 1 ------ Others
move $a0, $t0 ------ Others
addi $t4, $t6, 4 ------ I Type
li $v1, 4 ------ Others
la $a1, newLine ------ Others
j while ------ J Type
li $v2, 10 ------ Others
---------------------------------------------------------------
Total Lines w/o Comments = 25
Total Valid Instructions = 11
Backward Loops/JUMP = 1
Forward LOOPS/JUMP = 0
---------------------------------------------------------------
---------------------------------------------------------------
BACKWARD LABEL FORWARD LABEL
while -------
---------------------------------------------------------------

---------------------------------------------------------------
Names of Register used = v0 v1 a0 a1 t0 t1 t3 t4 t6
Total number of registers = 9
---------------------------------------------------------------

---------------------------------------------------------------
Total RAW Dependency = 3
---------------------------------------------------------------

--------------------DEPENDENT INSTRUCTIONS---------------------
addi $t0, $t0, 0 ---> addi $t3, $t0, 4
addi $t0, $t0, 0 ---> move $a0, $t0
lw $t6, myArray($t2) ---> addi $t4, $t6, 4
---------------------------------------------------------------

Download the CA_Lab9_mipsProgramAnalysis_Template.zip and rename the folder as <CampusID>_


CA_Lab9_mipsProgramAnalysis. Output must be stored as <CampusID>_CA_Lab9_opt1.txt,
<CampusID>_CA_Lab9_opt2.txt, <CampusID>_CA_Lab9_opbt3.txt and <CampusID>_
CA_Lab9_opt4.txt in the folder. Create a zip file <CampusID>_ CA_Lab9_mipsProgramAnalysis.zip,
which contains all the files mentioned above, and submit it in Quanta. Do not create archives in other
formats (rar, tar.gz etc). Once uploaded on Quanta, remember to submit it for grading. Do not leave it as a
draft.

/*###################################################################################
Note: Please don’t upload the assignments, template file/solution and lab. manual on GitHub or
others public repository.
Kindly remove them, if you have uploaded the previous assignments.
It violates the BITS’s Intellectual Property Rights (IPR).
************************************************************************************/

You might also like