hw1 - immediate field of an instruction), and big is a...

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

View Full Document Right Arrow Icon
EE 471 – Computer Design and Organization HW #1 – Due 12 October 2010 1.) Pseudo-instructions are not part of the MIPS instruction set but often appear in MIPS programs. The assembler then has to convert them into a small set of real MIPS instructions. For each of the following instructions, convert them to an equivalent (VERY short) set of real MIPS instructions. If you need a temporary variable, use $at (that’s what it is for). You will probably also want to read about the LUI (load upper immediate) instruction from Appendix B in the book. Pseudo-instruction What it accomplishes li $t1, big $t1 = big (note: solved below) clear $t0 $t0 = 0 beq $t1, small, L if ($t1 = small) go to L beq $t1, big, L if ($t1 = big) go to L bgt $t3, $t4, L if ($t3 > $t4) go to L lw $t5, big($t2) $t5 = Memory[$t2+big] Note that “small” is a constant that fits in 16 bits (i.e. small enough for the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: immediate field of an instruction), and big is a constant that is 32 bits (i.e. too long for the immediate field). If you need to access a portion of the constant, you can do that. For example, to implement li $t2, big, you would write: lui $at, big[31:16] # $ats top 16 bits set properly ori $t2, $at, big[15:0] # $t2s bottom 16 bits also set 2.) (C to MIPS) Exercise 2.19.1 for code segment (b). Assume a is in $a0, b in $a1, n in $a2, and the result should go into $v0. You may change the values in any of these registers. Note that to implement the subroutine call by simply jumping to the top of your code, but with the arguments updated appropriately. To end your program, call jr $ra to return to the subroutine caller. Shorter and faster programs will be given more credit....
View Full Document

Ask a homework question - tutors are online