CS0445 Project 1 Due February 9 (at the beginning of class). The purpose of this assignment is to write your first assembly language program and to test your ability to analyze program execution time. See the announcements web page for details about what to submit. PROJECT: Write a program in MIPS R2000/R3000 Assembly language that computes and outputs the CPU execution time for a program in nano-seconds. Assuming that instructions requires 3, 4 or 5 cycles to execute, the user should be prompted for the number of each type of instructions in the program as well as the clock period (in nano-seconds). EXAMPLE: Enter the number of 3-cycle instructions: 25 Enter the number of 4-cycle instructions: 30 Enter the number of 5-cycle instructions: 12 Enter the clock period in nano-seconds: 10 CPU time = 2550 ns Use your program to compare the efficiency of the two programs prog1 and prog2 found in files ~melhem/spim/examples/prog1 and ~melhem/spim/examples/prog2 on the cis unix system. Do not include the last two lines of the programs (li and syscall) in your analysis. Assume that the clock period is 8 nano-seconds and that - "la", "li" and "move" are 3-cycle instructions, - "add", "addi", "slt" and "bne" are 4-cycle instructions, - "sw" is a 5-cycle instructions. You will have to trace prog1 and prog2 by hand to determine the number of instructions of each type that actually execute. It may be clearer for you to start by writing a C++ program that computes the execution times, and then convert your C++ program to assembly language. ======================================================================= # ~melhem/spim/examples/prog1 contains the following program # Declare data .data array: .word 1,2,3,4,5,6,7,8 # A program to zero the above array .text .globl main main: la $s0, array # put base address of array in $s0 li $s1, 8 # put array size in $s1 move $t0, $zero # i = 0 loop: add $t1,$t0,$t0 # $t1 = i * 2 add $t1,$t1,$t1 # $t1 = i * 4 add $t2,$s0,$t1 # $t2 = &array[i] sw $zero,0($t2) # array[i] = 0 addi $t0,$t0,1 # i = i + 1 slt $t3,$t0,$s1 # $t3 = (i < array size) bne $t3,$zero,loop # if () go to loop li $2, 10 # prepare to exit with syscall 10 syscall # make call # end of program =================================================================== # ~melhem/spim/examples/prog2 contains the following program # Declare data .data array: .word 1,2,3,4,5,6,7,8 # A program to zero the above array using pointers. .text .globl main main: la $s0, array # put base address of array in $s0 li $s1, 8 # put array size in $s1 move $t0, $s0 # p = &array[0] add $t1,$s1,$s1 # $t1 = size * 2 add $t1,$t1,$t1 # $t1 = size * 4 add $t2,$s0,$t1 # $t2 = &array[size] loop: sw $zero,0($t0) # memory[p] = 0 addi $t0,$t0,4 # p = p + 4 slt $t3,$t0,$t2 # $t3 = (p < &array[size]) bne $t3,$zero,loop # if () go to loop li $2, 10 # prepare to exit with syscall 10 syscall # make call # end of program