CS0447 Project 1 Due Wednesday, February 9th, midnight The purpose of this assignment is to write your first assembly language program and to test your ability to analyze program execution time. WHAT TO SUBMIT: You will submit four files, one with the extension .s (an assembly language program), one with the extension .txt (a text file), and two with the extension .script (a script file showing the output of your program). A script file is a copy or recording of the interaction of the user of your program has with the computer. To begin a recording a script, enter the command 'script'. Then execute spim, not xspim (very important!), load your program and run it. When you do the script, for the input messages of your progam, type in the answers you got by tracing prog1. After you get the output from your program, quit spim and enter the exit command. A script file called "typescript" will be created. Rename this with a mv command. Example: %script Script started file is typescript %spim ....load and run your program ....quit from spim %exit %mv typescript yourfirstname_yourlastname.script1 Now do the same again, and type in the prog2 traced answers. Rename this typescript as yourfirstname_yourlastname.script2 SUBMISSION INSTRUCTIONS: Since all machines on campus are under AFS, you can simply use the cp command to copy your project files to the submission directory. Suppose Mary Doe wants to submit her project and has 4 files to submit: proj1.s, proj1.txt, proj1.script1, and proj1.script2 She can issue the following commands to submit her project files: %cp proj1.s /afs/cs.pitt.edu/usr0/moir/public/447/submission_1/mary_doe.s %cp proj1.txt /afs/cs.pitt.edu/usr0/moir/public/447/submission_1/mary_doe.txt %cp proj1.script1 /afs/cs.pitt.edu/usr0/moir/public/447/submission_1/mary_doe.script1 Execute another command like the one above for script2. Warning: Once you have copied files to the submission directory, you can't read, write or delete the files. So, be sure to submit the final version of the files to the directory. The time stamps of the submitted files will be compared with the time it is due, to check that projects are on time. PROJECT: Write a program in MIPS Assembly language that computes and outputs the CPU execution time for a program in nano-seconds. Assuming that each instruction requires 1, 3 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 1-cycle instructions: 25 Enter the number of 3-cycle instructions: 30 Enter the number of 5-cycle instructions: 12 Enter the clock period in nano-seconds: 5 CPU time = 875 ns Hint: it may be easier for you to start by writing the program in your favorite high-level programming language, and then converting your program to assembly language. Suppose we have a computer in which - "la", "li", "slt", "bne" and "move" are 1-cycle instructions, - "add" and "addi" are 3-cycle instructions, - "sw" is a 5-cycle instruction. Trace prog1 and prog2 by hand to determine the number of instructions of each type they actually execute. These programs can be found in files ~moir/public/cs0447/prog1 and ~moir/public/cs0447/prog2 on the CIS unix system, and are also shown below. Make a table in your .txt file showing the number of instructions of each type executed by each program. Also calculate the average CPI for each program, and include this information in your .txt file. Now, use your program to compare the execution times of the two programs prog1 and prog2. 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. ======================================================================= # ~moir/public/cs0447/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 =================================================================== # ~moir/public/cs0447/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