hw-01 - sequence to multiply the value stored in $a0 by 31...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 341 Fall 2011 Homework #1 1. Write a MIPS assembly language program to divide a value stored in $a0 by a value stored in $a1. Register $v0 should store the quotient, and $v1 the remainder. 2. Consider the following MIPS assembly language program. Write an equation that describes the expression that is evaluated in terms of $s0, $s1, $s2, and $v0. add $v0, $0, $0 # Begin Division add $t0, $0, $s0 # $v0 = Quotient add $t0, $0, $s1 # $s0 = Dividend slt $t3, $s0, $s1 # $s1 = Divisor bne $t3, $0, after sub $t0, $t0, $s1 # Operand Order: $t0 - $s1 again: sub $t0, $t0, $s1 slt $t3, $t0, $0 beq $t3, $0, again addi $v0, $v0, 1 # End Division after: sub $v0,$s2, $v0 sll $v0, $v0, 1 3. Using a shift left logical instruction (SLL) and one other MIPS instruction, write an instruction
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sequence to multiply the value stored in $a0 by 31. The result should be stored in register $a0. 4. Write a MIPS assembly language program to multiply two signed integers stored in register $a0 and $a1 and return the product in $v0. You may use the following registers: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $s0, $s1, $s2, $s3, $s4, $s5, $s6, $s7, $a0, $a1, $v0. 5. Convert the pseudoinstruction ble $s2, $v0, convert to native MIPS instructions. 6. Describe why optimal code is important. Be sure to address a wide variety of issues including economic and environmental....
View Full Document

This document was uploaded on 11/03/2011 for the course CSE 341 at SUNY Buffalo.

Ask a homework question - tutors are online