#### LSU EE 3755 Spring 2009 MIPS Homework template.############# #### Instructions: #### #### Copy this to a file( name it s09.asm) and save on your class account. ### Use this file for your solution. #### Your entire solution should be on this file. ## ## Problem 0 : Write down your name and your account. ## Your Name : ####### ## Your Account: ####### ## Problem 1(20pts): ## LOOP: ## 0x400000 add $s3, $s1, $s2 ## addi $s2, $s2,0x20 ## nop ## beq $s1, $s2, LOOP ## (For the problem 1) ## Write Machine code for the above 4 instructions without looking the Book or Notes. ### (Hexadecimal format) ## Hint: ###opcode for add is 0 and func field is 0x20. ###opcode for addi is 8 and think about rt and rs fields. ###opcode for beq is 4 ###register number for $s0 is 16 ## your answer for the problem 1. ## ## ## ## ## ##// Problem 2(20pts): Branch target address. ##2.1)Compute this branch target address for delayed branch(5pts) ## 0x400000 bne $s0, $s1, 4 ## your answer ## ##2.2)Compute this branch target address for non-delayed branch(5pts) ## 0x400000 bne $s0, $s1, 4 ## your answer ## ##2.3) Compute this branch target address for delayed branch(5pts) ##0x40001c bne $s0,$s1,-2 ## your answer ## ##2.4)Compute this branch target address for non-delayed branch(5pts) ##0x40001c bne $s0,$s1,-2 ## your answer ## ## Problem 3(10pts): Convert these pseudo code expression into real MIIPS instructions. ## ##3.1) seq $s0,$s1,$s2 ## seq rdest, rsrc1,rsrc2 : set equal: ## your answer ## ## ## ## ## ## ## ##3.2) $s0 = phi * $t1 * $t2 ## phi = 3.1415 ## your answer ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## Problem 4(10pts): Fill code in the program. ## Fill the code at &&&&& ## ## ## .data ## string: ## .asciiz "The summations of the two numbers are \n" ## eq_msg: .asciiz " = " ## add_msg: .asciiz " + " ## newline: .asciiz "\n" ## ## ## .align 4 ## NUM1: .word 10 ## .word 20 ## .word 30 ## .word 40 ## .word 50 ## .word 60 ## .word 70 ## .word 80 ## .word 90 ## ## NUM2: .word 1 ## .word 2 ## .word 3 ## .word 4 ## .word 5 ## .word 6 ## .word 7 ## .word 8 ## .word 9 ## RESULT1: .space 100 # for saving the result ## ## .text ## .globl main ## main: ## ## ## la $t0, string # stores the address for string in $t0 ## la $s1, NUM1 ## la $s2, NUM2 ## la $s3, RESULT1 ## addi $t5, $0, 4 # for address increment ## addi $t6, $0, 9 # for loop counter. ## li $v0, 4 ## la $a0, string ## syscall ## ##TOP: lw $s4, 0($s1) ## lw $s5, 0($s2) ## &&&&& <======figure out this command.########### ## your answer: ########### ## sw $s6, 0($s3) ## # Displays the First Number ## or $a0, $0, $s4 ## li $v0, 1 ## syscall # Displays the " + " ## la $a0, add_msg ## li $v0, 4 ## syscall # Displays the Second number ## or $a0, $0, $s5 ## li $v0, 1 ## syscall # Displays the " = " ## la $a0, eq_msg ## li $v0, 4 ## syscall # Displays the Resulting number ## or $a0, $0, $s6 ## li $v0, 1 ## syscall # Return Carriage ## la $a0, newline ## li $v0, 4 ## syscall ## addi $t6, $t6, -1 ## addi $s1, $s1, 4 ## addi $s2, $s2, 4 ## addi $s3, $s3, 4 ## bne $0, $t6, TOP ## ## ## ## ##//Problem 5(40pts) ##Use main at the beginning instead of __start and ##assume delayed branch when you are using xspim or pcspim . ##Write a MIPS program to show statistics for a paragraph(textdata) ##After scanning textdata, you are required to write a program to show the total number of vowels in the paragraph(textdata). For the simplicity of the program, assume every character in the paragraph is upper case. ##The output format is given below. ## ## ## Output format: ## The total number of vowels in the sentence = ## Vowel ={A,E,I,O,U} ############################################################# ##(Look at the problem 4 of Spring 2007 MIPS Homework. You can do this by modifying the solution code for the problem 4 ). ## ## .data textdata: .asciiz "IN A DISTANT GALAXY EONS BEFORE THE CREATION OF THE MYTHICAL PLANET KNOWN AS EARTH, VAST CIVILIZATIONS HAVE EVOLVED, AND RULING THE GALAXY IS AN INTERSTELLAR EMPIRE CREATED FROM THE RUINS OF AN OLD REPUBLIC THAT HELD SWAY FOR GENERATIONS \n" return: .asciiz "\n" word_msg: .asciiz " The total number of vowels in the sentence = " .align 4 .text .globl main main: