EE3755 MIPS Homework Due date April 30, 2008

advertisement
EE3755 MIPS Homework Due date April 30, 2008
Estimated time to solve:
Prob.1
// machine code;
10
minutes(20pts).
Prob.2
// address computation;
10
minutes(20pts).
Prob.3
// pseudo code ;
10
minutes(10pts).
Prob.4
// writing a program
4
hours( 50pts).
When you work at home, for installing PCSpim and psftp
Uploading files to the department computer
Total
30 minutes.
20 minutes.
5 hours and 20 minutes.
How to submit?
//No hard copy.
//Copy the template file from /home/classes/ee3755/com/sol.asm
//Do all of your work on the solution file(sol.asm).
//Answer to the questions for problem 0,1,2,3 on the file( sol.asm).
//Run solution file by using xspim and save the output to sol.txt file
//(How to save it? Just copy from the output screen to sol.txt file)
//Leave your solution file(sol.asm) and output file(sol.txt) on your account.
## Do all your work on sol.asm file for the problem 0 , problem 1, problem 2, problem
3,and problem 4.
## Problem 0 : Write down your name and your account.
##
Your
Name :
#######
##
Your
Account: #######
## Problem 1(20pts):
LOOP:
0x400000
addi
add $s2, $s2, $s3
$s1, $s2,0x20
nop
1
beq
$s2, $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
// Problem 2(20pts): Assume delayed branch.
2.1)Compute this branch target address(10pts)
0x400000
bne $s0, $s1, 3
2.2)compute this branch target address(10pts)
0x40001c
bne $s0,$s1,-3
## Problem 3(10pts): Convert these pseudo instructions into real instructions.
3.1) seq
$s0,$s1,$s2
3.2) li
$s1,0x1111
#seq rdest, rsrc1,rsrc2 : set equal:
##Writing Program.
Just add more code to the template file(sol.asm).
//Problem 4
Use “
assume
main” at the beginning instead of “__start ” and
delayed branch
when you are using xspim or pcspim .
Write a MIPS program to show word statistics for a paragraph(textdata)
After scanning textdata,
you are required to write a program to show how many words
are ending with each characters. The output format is given below. Ignore everything
after numbers.
2
(for example //{A} so 1, this one is given to help you understand the problem. The
actual format is something like
“A
=1”)
Output format:
Occurrences
of
word
ending with
A
=
1
//{ A}
B
=
0
//
C
=
0
//
D
= 0
//
E
=
//{BEFORE, THE,THE}
3
:
so 1
so 3
…..
Z =
#############################################################
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 ).
#
$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
.data
textdata:
.asciiz "IN A DISTANT GALAXY EONS BEFORE THE CREATION OF THE
MYTHICAL PLANET KNOWN \n"
return:
3
.asciiz "\n"
newline:
.asciiz "\n"
word_msg:
.asciiz
eq_msg:
.ascii
" Occurrences
of
word
ending with \n"
"="
.align 4
TABLE2: .space 104
# for temporary use
.align 4
TABLE4: .space 104
# for occurences
.text
.globl main
main:
4
Download