------------------------------------ Due Friday Will be collected Friday night.
Create a text file on Odin named 2240/5/a5.txt
You may answer all the questions, but there are some questions
that require an answer.
They are identified in the hints.
------------------------------------
1. MIPS is a load/store architecture. What does this mean?
2. MIPS requires that most data to be aligned. What does this mean?
3. What are the restrictions on label names in MIPS?
4. What does this assembler directive accomplish?
stuff: .byte 'a','b','c','d','e','g'
5. What do these assembler directives accomplish?
stuff: .space 15
stuff2: .word 0:10
6. Since MIPS instructions are all one word (4 bytes), it is easy to compute
the address of the next instruction even if the instructions vary by number
of operands. Give the addresses of the next two instructions after addi.
Address Instruction
0x00400024 addi $t2, $t3, 5
__________ la $a0, mystuff
__________ b target
7. It is easy to encode MIPS instructions since there are so few instruction
types (I, R and J). The encoding format for this type
I instruction with opcode 8
Addi is opcode 8, rt is register target, rs is
register source, and imm is the immediate value.
What is the binary encoding of this addi instruction?
(The opcode for addi is 8. See quick guide for register numbers. )
8. Pseudoinstructions are macros added to MIPS to make life
easier for the programmer. The assembler translates pseudos
into actual instructions; e.g., this pseudo:
move $t1, $s3 # $t1 = $s3
is really, under the covers, an add operation. Provide the
equivalent MIPS add. Why provide a macro for a single instruction?
9. Most pseudoinstructions are macros for multiple MIPS instructions. For
example, the bgt pseudo is really three instructions: beq, slt and bne.
Explain the meaning of the bgt below and translate it into its
equivalent three MIPS instructions beq, slt and bne.
bgt $t0, $s2, Label
10. Using Appen A-10 or the quick guide as a reference, write a brief comment
for each line of MIPS code below. Then explain what the code is doing.
Assume that $s2 holds the starting address of an array of five integers
1,2,3,4,5.
11. The following is the machine language of a small MIPS program.
What does the program do?
00110100000001000000000000001010
00100000100001000000000000010100
00110100000000100000000000000001
00000000000000000000000000001100
Note:
The question is not either of the following:
Show this program as MIPS assembly language instructions.
-or-
Explain each of the statements in this machine language program.
12. Write MIPS program statements that will branch to a label named BIG if
the value stored in register $v0 is greater than the value one million.
13. Write MIPS programming statements that will branch to a label named LARGE
if the value stored at the address in register $a0 is greater than the value
two million.
14. Your MIPS program has an array of integers defined like so:
.data
arr: .space 100
Each integer is stored as a word (4-bytes).
Write MIPS program statements that will branch to a label named START if the
value stored in the first array element is the value 123.
Do not write a complete program.
Do not write a loop.
Assume there is a label START: somewhere in the program.
Do write all the statements necessary.