{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Is at label if s4 s5 next instr is at label if s4 s5

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s3 $s1 = Memory[$s2+100] Memory[$s2+100] = $s1 Next instr. is at Label if $s4 ≠ $s5 Next instr. is at Label if $s4 = $s5 Next instr. is at Label R op rs rt rd I op rs rt 16 bit address J op shamt funct 26 bit address 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 26 Three Ways to Jump: j, jr, jal j instr jr $ra jal addr Spring 2013, Jan 25 . . . Spring # jjump to machine instruction instr ump instr (unconditional jump) (unconditional # jump to address in register ra (used by calee to go back to caller) (used # set $ra = PC+4 and go to addr set addr (jump and link; used to jump to a procedure) ELEC 5200-001/6200-001 Lecture 3 27 Control Flow We have: beq, bne, what about Branch-if-less-than? New instruction: if $s1 < $s2 then $t0 = 1 slt $t0, $s1, $s2 else $t0 = 0 Can use this instruction to build new “pseudoinstruction” blt $s1, $s2, Label Note that the assembler needs a register to do this, Note — there are policy of use conventions for registers 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 28 Pseudoinstructions blt $s1, $s2, reladdr Assembler converts to: slt $1, $s1, $s2 slt bne $1, $zero, reladdr Other pseudoinstructions: bgt, ble, bge, li, move Not implemented in hardware Assembler expands pseudoinstructions into Assembler machine instructions machine Register 1, called $at, is reserved for converting Register pseudoinstructions into machine code. pseudoinstructions Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 29 Policy of Register Usage Policy (Conventions) (Conventions) Name Register number $zero 0 $v0-$v1 2-3 $a0-$a3 4-7 $t0-$t7 8-15 $s0-$s7 16-23 $t8-$t9 24-25 $gp 28 $sp 29 $fp 30 $ra 31 Usage the constant value 0 values for results and expression evaluation arguments temporaries saved more temporaries global pointer stack pointer frame pointer return address Register 1 ($at) reserved for assembler, 26-27 for operating system 2004 © Morgan...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern