Reference no: EM132413926 , Length: word count:500
AST10201 - Computer Organization - City University of Hong Kong
A. Objective
1. Solve real life problem using MIPS assembly language
2. Evaluate the performance of a program in QtSpim
3. Understand how computer organization affects the execution time of computer programs.
B. Requirements of the MIPS assembly program
Write an MIPS assembly program named as "numberConverter_[studentID].s". The requirements for this program are listed below:
Step 1: The program allows user to input any number such as binary number with prefix "b", octal number with prefix "0" (noted that it is not "o"), decimal number without any prefix, hexadecimal with prefix "0x". Assume the input number is a unsigned 32-bit number.
Hints:
1. You may create an enough buffer for the input string. For example: You define a buffer with 33 bytes in .date.
buffer: .space 33
Later on, in .text you can save the input number into buffer you define, using following instructions:
la $a0, buffer li $a1, 33
li $v0, 8 # read String syscall
2. You may want to know which base of number user input. Using the following instructions, you can read the first character from buffer into $s0:
lb $s0, 0($a0) # first character in buffer
If $s0 is equal to ‘b' then you know the input number should be binary, and so on.
3. You may also want to know the length of number user input. Using the following instructions, $a1 would be equal to the digits user inputs excluding the prefix, assuming now $a0 is the address of the first digit (not prefix, you need to modify
$a0 first):
length: lb $s0, 0($a1)
beq $s0, 10, endString # 10 is the ascii code of new line
addi $a1, $a1, 1 j length
endString:
sub $a1, $a1, $a0
Step 2: Convert the number user entered to another 3 different number systems.
Step 3: In console window, the program will ask user "Do you wanna continue (y/n)?". If enter "y", Step 1 and Step 2 are repeated. If enter "n", it responses "End" to indicate the end of the program.
Your program result should be the same as the following figure. The underlined number or characters in the following figure are inputted by user.
C. Report
Write a report named "report_[studentID].docx". The requirements for this report are listed below:
1. Assume now user inputs b10100. Explain how many instructions will be executed in "str2int" procedure.
2. If your program is run on a pipelined CPU with MIPS architecture, which kind of hazards will happen in your program? Indicate and explain them.
3. Explain which part of your code can be optimized to reduce the execution time of the program. Can you try to make the size of file, numberConverter_[studentID].s, not greater than 5 KB?
Attachment:- Computer Organization.rar