#### LSU EE 3755 Fall 2009 MIPS Homework template.############# #### Instructions: #### #### Copy this to a file( name it f09.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, $s2, $s1 ## addi $s1, $s3,0x20 ## nop ## beq $s1, $s3, 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, 2 ## your answer ## ##2.2)Compute this branch target address for non-delayed branch(5pts) ## 0x400000 bne $s0, $s1, 2 ## your answer ## ##2.3) Compute this branch target address for delayed branch(5pts) ##0x40001c bne $s0,$s1,-3 ## your answer ## ##2.4)Compute this branch target address for non-delayed branch(5pts) ##0x40001c bne $s0,$s1,-3 ## your answer ## ##//Problem 3(60pts) ##Use main at the beginning instead of __start and ##assume delayed branch when you are using xspim or pcspim . ##Write a MIPS program to print the text just like output format (which is given) after you read the text(textdata) ##After scanning textdata, you are required to write a program to print a) whole text b)you save wards at a ##memory(the starting address of this memory is “saved_words”) and print words from the memory one at a ##time c) you print the words at the memory in reverse order. Words here means character or group of ##characters separated by space. For the simplicity of the program, assume every character in the paragraph ##is upper case. When you save the words at the memory(the starting address of this memory is “saved_words## ”) for b), you separate words by putting space between words. ############################################################# ##(Look at the problem 4 of Spring 2007 MIPS Homework. The code will help you a little bit) ## .data textdata: .asciiz "IN A DISTANT GALAXY EONS BEFORE THE CREATION OF THE MYTHICAL PLANET KNOWN AS EARTH \n" return: .asciiz "\n" word_msg: .asciiz " The text is " .align 4 word_msg1: .asciiz " The saved words are " .align 4 word_msg2: .asciiz " The words which are printed in reverse order " .align 4 .text .globl main main: ##hint: use .space to save the words at .data ##for example: saved_words: .space 300 //to save the words ## //at this memory location