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

Info iconThis 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

Ask a homework question - tutors are online