## Problem 0 : Write down your name and your account. ## Your Name : ######### ## Your Account: ######### ## Problem 1(20pts): ## LOOP: ## 0x400000 add $t1, $s1, $s2 ## addi $t1, $t2,0x10 ## nop ## beq $t1, $t2, 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 ## register number for $t0 is 8 ## P1: Your solution comes here. ## 0x ## 0x ## 0x ## 0x ## ## // Problem 2(20pts): Assume non delayed branch. ## 2.1)Compute this branch target address(10pts) ## 0x400000 bne $s0, $s1, 4 ## Your solution comes here ## 0x ## ## 2.2)compute this branch target address(10pts) ## ## 0x40001c bne $s0,$s1,-2 ## Your solution comes here ## 0x ##Writing Program. ## Just add more code to the template file(sol.asm). ##//Problem 3 ##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 word statistics for a paragraph(textdata) ##Do all work at sol.asm file and answer the questions. ##Don’t forget using “#” when you are answering questions. ##You required to write a program to show how many words are starting with ##each characters and print corresponding words. ##The output format is given below. ##(for example B = 1 BEFORE. The actual format is ## something like “ A = 1 ” and print A. ## For T, there are 2 “THE”. You have to do something like “T =2’ ## and print “THE” twice.) ##Output format: ## Occurrences of word starting with : ## A = 1 ## A ## B = 1 ## BEFORE ## C = 1 ## CREATION ## … ## ## ## ….. ## Z = ############################################################# ## problem 3.1(5pts) ## One way to solve this problem is you scan the whole text once and ## count the words starting with "A" and you scan again to print the words ## starting with "A". You have to do this for "B" ,"C" and so on. ## What will be the drawbacks for this kind of approach? ## your answer comes here ## ## ## ## ## problem 3.2(10pts) ## Explain your program for solving this problem ## ( What will be your approach for the better algorithm than ## the method at the problem 3.1?) ## your answer comes here ## ## ## ## ## ## ## ## ## ## ## ##Assume the longest word length is 25: ## ##(Look at the problem 4 of Spring 2007 MIPS Homework. ##You can do this by modifying the solution code for the problem 4 ##and adding new code for printing corresponding words). ## $t0 = location of the string ## $t1 = hold scanned character ## $s2 = holds the ascii value for a space(32) ## $t3 = used for address computation ## $s5 = used for starting address of TABLE2 for a word statistics ## $s4 = used for starting address of TABLE4 for sentence statistics ## $s0 = holds the word length cnt ## $s1 = holds the address for TABLE ## problem 3.3 ## Write code and do simulation(45pts) ## .data textdata: .asciiz "IN A DISTANT GALAXY EONS BEFORE THE CREATION OF THE MYTHICAL PLANET KNOWN \n" ## Assume all letters at textdata are upper case for the simplicity return: .asciiz "\n" newline: .asciiz "\n" word_msg: .asciiz " Occurrences of word starting with \n" eq_msg: .ascii " = " .align 4 TABLE2: .space 104 # for temporary use .align 4 TABLE4: .space 104 # for occurences #you may have to add more TABLE for corresponding words .text .globl main main: