Topic(s): Assembly Language, and the MIPS Instruction Set
Related Reading: class notes, and the MIPS Assembly Language and Simulator links.
Read the directions for Getting Started with the MARS simulator.
You are allowed to submit your assignment via email, but if you choose to do so, you must bring a hardcopy of your assignment along with a completed cover sheet to the instructor at the next class. (Note: Do not email the instructor any .zip file attachments, as SLU's email may not accept these emails; i.e. the instructor may not receive your email.)
Indicate what registers are modified by the following instructions, and what their new values will be:
Assume that the initial values in the registers are:
$s0 = 0x1F $s2 = 0x62 $s4 = 0x0C $t1 = 0x47
Given the following snippet of AVR assembly code (which you can also download: hwk4_problem2.asm), answer the questions below:
Note: In this program, N is a variable stored in memory.
li $t0, 9 li $t4, 0 lw $s3, N # 'N' is a variable stored in memory (with some unknown value) Loop: beq $s3, $t4, Exit addi $t0, $t0, 4 addi $s3, $s3, -1 j Loop Exit: sw $t0, f_N # 'f_N' is the result, stored as the variable 'f_N' in memory
Given the following list of potential mathematical expressions:
(1) y = -3 * x (2) y = 8 * x - 3 (3) y = (x * 4) + (x - 8) (4) y = -1 (5) y = (4 * x - 1) / 8 (6) y = (8 * x) + (x - 3) (7) y = 4 * x - 8 (8) y = (x / 8) + (4 * x) (9) y = x - 12
Which of the above mathematical expressions does each of the following assembly code sequences correspond to?
Note: I would recommend that you try to figure out the answers to these problems without using the simulator. But you may want to use the simulator to verify your answers (e.g. here is the code for part b: hwk4_problem3b.asm).
lw $s0, x li $s4, 3 sll $s0, $s0, 3 sub $s0, $s0, $s4 sw $s0, y
lw $s0, x li $s4, 3 mul $s4, $s4, 4 sub $s0, $s0, $s4 sw $s0, y
lw $s0, x mul $s0, $s0, 4 addi $s0, $s0, -1 srl $s0, $s0, 3 sw $s0, y