{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lec04b - Assembly bne $s3 $s4 Else add $s0 $s1 $s2 j Exit...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 COMP 4300 Computer Architecture Operations in the Instruction Set Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin [email protected] Fall, 2010
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Review Memory Addressing Types of Instructions
Background image of page 2
3 I-Format vs. R-Format Instructions Compare with R-Format offset 6 bits 5 bits 5 bits 16 bits I-Format op rs rt rd funct shamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R-Format op rs rt Note similarity!
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 I-Format Example Machine language for lw $9, 1200($8) == lw $t1, 1200($t0) op rs rt offset 6 bits 5 bits 5 bits 16 bits Binary Decimal 35 8 9 1200 100011 01000 01001 0000010010110000 0 31
Background image of page 4
5 MIPS Conditional Branch Instructions Conditional branches allow decision making beq R1, R2, LABEL if R1==R2 goto LABEL bne R3, R4, LABEL if R3!=R4 goto LABEL Example C Code if (i==j) goto L1; f = g + h; L1: f = f - i; Assembly beq $s3, $s4, L1 add $s0, $s1, $s2 L1: sub $s0, $s0, $s3
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Example: Compiling C if-then-else Example C Code if (i==j) f = g + h; else f = g - h;
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Assembly bne $s3, $s4, Else add $s0, $s1, $s2 j Exit; # new: unconditional jump Else: sub $s0, $s1, $s2 Exit: • New Instruction: Unconditional jump j LABEL # goto Label 7 Binary Representation - Branch • Branch instructions use I-Format • offset is added to PC when branch is taken beq r0, r1, offset has the effect: if (r0==r1) pc = pc + 4 + ( offset << 2 ) else pc = pc + 4; • Offset is specified in instruction words ( why? ) • What is the range of the branch target addresses? op rs rt offset 6 bits 5 bits 5 bits 16 bits Conversion to word offset 8 Branch Example • Machine language for beq $s3, $s4, L1 add $s0, $s1, $s2 L1: sub $s0, $s0, $s3 op rs rt offset 6 bits 5 bits 5 bits 16 bits Binary Decimal 4 19 20 1 000100 10011 10100 0000000000000001 $19 $20 PC PC+4 Target of beq 1-instruction offset 31...
View Full Document

{[ snackBarMessage ]}

Page1 / 8

Lec04b - Assembly bne $s3 $s4 Else add $s0 $s1 $s2 j Exit...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online