Addressing in Jumps jump j Label go to Label op address 2 address

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

The University of Adelaide, School of Computer Science
Lecture 20: 11/12/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Lecture 9: MIPS Instruction Set
©UCB CS 161 Lecture 4 Prof. L.N. Bhuyan
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
Solution 2nd Exam.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
MIPS Calling Convention Chapter 2.7 Appendix A.6.
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
Assembly Code Example Selection Sort.
The University of Adelaide, School of Computer Science
Computer Organization CS224
Csci136 Computer Architecture II Lab#4. - Stack and Nested Procedures
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 4 Assembly Language Programming 2.
The University of Adelaide, School of Computer Science
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
CS3350B Computer Architecture Winter 2015 Lecture 4
Lecture 8: MIPS Instruction Set
MIPS Coding. Exercise – the bubble sort 5/8/2015week04-3.ppt2.
Assembly Language II CPSC 321 Andreas Klappenecker.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
CSCE 212 Quiz 2 – 2/2/11 1.What is the purpose of the jal instruction? 2.What are the two conditional branching (if, goto; not the slt instruction) instructions.
1 Lecture 5: MIPS Examples Today’s topics:  the compilation process  full example – sort in C Reminder: 2 nd assignment will be posted later today.
Computer Structure - The Instruction Set (2) Goal: Implement Functions in Assembly  When executing a procedure (function in C) the program must follow.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
MIPS function continued. Recursive functions So far, we have seen how to write – A simple function – A simple function that have to use the stack to save.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
Computer Architecture CSE 3322 Lecture 4 crystal.uta.edu/~jpatters/cse3322 Assignments due 9/15: 3.7, 3.9, 3.11.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
Branch Addressing op rs rt address address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 8: MIPS Procedures and Recursion.
MIPS Subroutines Subroutine Call – jal subname Saves RA in $31 and jumps to subroutine entry label subname Subroutine Return – jr $31 Loads PC with return.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic4: Procedures José Nelson Amaral.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 12 Procedure Calling.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 14, 15 Addressing Mode.
CPEG323 Homework Review I Long Chen October, 17 th, 2005.
Computer Architecture & Operations I
Computer Architecture & Operations I
Lecture 5: Procedure Calls
Prof. Hsien-Hsin Sean Lee
Lecture 6: Assembly Programs
Computer Architecture Instruction Set Architecture
Lecture 4: MIPS Instruction Set
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Procedures (Functions)
The University of Adelaide, School of Computer Science
CSCI206 - Computer Organization & Programming
Instructions - Type and Format
Solutions Chapter 2.
Logical and Decision Operations
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Lecture 7: Examples, MARS, Arithmetic
Lecture 5: Procedure Calls
Logical and Decision Operations
Chapter 2 Instructions: Language of the Computer part 2
MIPS function continued
Lecture 6: Assembly Programs
Systems Architecture I
Computer Architecture
MIPS function continued
Presentation transcript:

Addressing in Jumps jump j Label go to Label op address 2 address 6 bits 26 bits The complete 32 bit address is : address 00 4 bits 26 bits 2 bits Upper 4 bits of the Program Counter, PC jump uses word addresses address * 4 = address:00 This is Pseudodirect Addressing. Note: 256 MB word boundaries – 64M Instructions

Branch Addressing beq $s1, $s2, Label if ($s1 = =$s2) go to Label op rs rt address 4 17 18 address 6 bits 5 bits 5 bits 16 bits effective 32 bit address = ( PC + 4 ) + ( address * 4 ) Next Instruction address is the relative number of instructions address * 4 = address : 00 This is PC-relative addressing

Branch Addressing bne $t1, $s1, Label # if $t1!= $s1 goto Label What if Label is more words than 16 bits ? ( 64K instructions or 256 KB )

Branch Addressing bne $t1, $s1, Label # if $t1!= $s1 goto Label What if Label is more words than 16 bits ? (±32K instructions) Then change to the complement branch and add a jump. beq $t1, $s1, L2 # if $t1 = $s1 goto L2 j Label L2:

Sort an array v[n-1] • v[j+1] v[j] v[2] v[1] v[0]

Swap procedure Swap the contents of v[ k ] and v [ k + 1 ] swap ( int v[ ], int k ) { int temp; temp = v[ k ]; v[ k ] = v[ k + 1 ]; v[ k + 1 ] = temp ; }

Swap procedure } swap ( int v[ ], int k ) { int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ; } leaf procedure $a0 = v base, $a1 = k Use $t0 for temp Save $a0, $a1, $ra ?

Swap procedure } swap ( int v[ ], int k ) { int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ; } leaf procedure $a0 = v base, $a1 = k Use $t0 for temp swap: add $t1, $a1, $a1 # $t1 = k * 2 add $t1, $t1, $t1 # $t1 = k * 4 add $t1, $a0, $t1 # $t1 = v base + k * 4

Swap procedure swap ( int v[ ], int k ) {int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ;} leaf procedure $a0 = v base, $a1 = k Use $t0 for temp swap: add $t1, $a1, $a1 # $t1 = k * 2 add $t1, $t1, $t1 # $t1 = k * 4 add $t1, $a0, $t1 # $t1 = v + k * 4 lw $t0, 0 ( $t1 ) # temp = v[ k ]

Swap procedure swap ( int v[ ], int k ) {int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ;} leaf procedure $a0 = v base, $a1 = k Use $t0 for temp swap: add $t1, $a1, $a1 # $t1 = k * 2 add $t1, $t1, $t1 # $t1 = k * 4 add $t1, $a0, $t1 # $t1 = v + k * 4 lw $t0, 0 ( $t1 ) # temp = v[ k ] lw $t2, 4 ( $t1 ) # $t2 = v[ k + 1 ] sw $t2, 0 ( $t1 ) # v[ k ] = $t2

Swap procedure swap ( int v[ ], int k ) {int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ;} leaf procedure $a0 = v base, $a1 = k Use $t0 for temp swap: add $t1, $a1, $a1 # $t1 = k * 2 add $t1, $t1, $t1 # $t1 = k * 4 add $t1, $a0, $t1 # $t1 = v + k * 4 lw $t0, 0 ( $t1 ) # temp = v[ k ] lw $t2, 4 ( $t1 ) # $t2 = v[ k + 1 ] sw $t2, 0 ( $t1 ) # v[ k ] = $t2 sw $t0, 4 ( $t1 ) # v[ k + 1 ] = temp

Swap procedure swap ( int v[ ], int k ) {int temp; temp = v[ k]; v[ k] = v[ k + 1 ]; v[ k + 1 ] = temp ;} leaf procedure $a0 = v base, $a1 = k Use $t0 for temp swap: add $t1, $a1, $a1 # $t1 = k * 2 add $t1, $t1, $t1 # $t1 = k * 4 add $t1, $a0, $t1 # $t1 = v + k * 4 lw $t0, 0 ( $t1 ) # temp = v[ k ] lw $t2, 4 ( $t1 ) # $t2 = v[ k + 1 ] sw $t2, 0 ( $t1 ) # v[ k ] = $t2 sw $t0, 4 ( $t1 ) # v[ k + 1 ] = temp jr $ra # return

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); } v[n-1] • v[j+1] v[j] v[2] v[1] v[0]

Sort on array for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1){ swap ( v, j );} i = 1 2 3 2 1 3 9 2 1 9 3 2 9 1 3 2 9 3 1 9 2 3 1 9 3 2 1 j = 0 1 0 2 1 0

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} This is a procedure that is called and calls another, “swap”. Assignment: $a0 to v base, $a1 to n to pass parameters $s0 to i, $s1 to j; Why not $t0 and $t1?

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} This is a procedure that is called and calls another, “swap”. Assignment: $a0 to v base, $a1 to n to pass parameters $s0 to i, $s1 to j; Why not $t0 and $t1? As a called routine, must push what?

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} This is a procedure that is called and calls another, “swap”. Assignment: $a0 to v base, $a1 to n $s0 to i, $s1 to j As a called routine, must push $s0, $s1 and $ra? Before calling swap must save ?

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} This is a procedure that is called and calls another, “swap”. Assignment: $a0 to v base, $a1 to n $s0 to i, $s1 to j As a called routine, must push $s0, $s1 and $ra? Before calling swap must save $a0 and $a1. Options?

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} This is a procedure that is called and calls another, “swap”. Assignment: $a0 to v base, $a1 to n $s0 to i, $s1 to j As a called routine, must push $s0, $s1 and $ra? Others? Before calling swap must save $a0 and $a1. Options? Use $s2 and $s3 for $a0 and $a1. Must push $s2 and $s3.

sort : addi $sp, $sp, -20 # move stack pointer sw $ra, 16 ($sp) # save $ra on stack sw $s3, 12 ($sp) # save $s3 on stack sw $s2, 8 ($sp) # save $s2 on stack sw $s1, 4 ($sp) # save $s1 on stack sw $s0, 0 ($sp) # save $s0 on stack add $s2, $a0, $zero # $s2 = $a0 = v base add $s3, $a1, $zero # $s3 = $a1 = n Procedure Body exit1: lw $s0, 0 ($sp) # restore $s0 from stack lw $s1, 4 ($sp) # restore $s1 from stack lw $s2, 8 ($sp) # restore $s2 from stack lw $s3, 12 ($sp) # restore $s3 from stack lw $ra, 16 ($sp) # restore $ra from stack addi $sp, $sp, 20 # restore stack pointer jr $ra # return

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} Outer loop for ( i = 0; i < n; i = i + 1 )

Procedure Body Outer loop $s0 = i, $s1 = j, $s3 = n for ( i = 0; i < n; i = i + 1 ) add $s0, $zero, $zero # i = 0

Procedure Body Outer loop $s0 = i, $s1 = j, $s3 = n for ( i = 0; i < n; i = i + 1 ) add $s0, $zero, $zero # i = 0 L1: slt $t0, $s0, $s3 # $t0 = 0 if i >= n beq $t0, $zero, exit1 # exit out if i >= n

Procedure Body Outer loop $s0 = i, $s1 = j, $s3 = n for ( i = 0; i < n; i = i + 1 ) add $s0, $zero, $zero # i = 0 L1: slt $t0, $s0, $s3 # $t0 = 0 if i >= n beq $t0, $zero, exit1 # exit out if i >= n Inner Loop exit2: addi $s0, $s0, 1 # i = i + 1 j L1 # jump to outer loop test

Sort on array sort ( int v[ ], int n ) { int i, j ; for ( i = 0; i < n; i = i + 1 ) { for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); }}} Inner Loop

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); addi $s1, $s0, -1 # j = i –1

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); addi $s1, $s0, -1 # j = i –1 L2: slti $t0, $s1, 0 # $t0 = 1, if j <0 bne $t0, $zero, exit2 # if j <0 go to exit2

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); addi $s1, $s0, -1 # j = i –1 L2: slti $t0, $s1, 0 # $t0 = 1, if j <0 bne $t0, $zero, exit2 # if j <0 go to exit2 add $t1, $s1, $s1 # $t1 = 2 * j add $t1, $t1, $t1 # $t1 = 4 * j add $t2, $s2, $t1 # $t2 = v + (4 *j) lw $t3, 0 ( $t2) # $t3 = v[ j ] lw $t4, 4 ( $t2) # $t4 = v[ j + 1]

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); addi $s1, $s0, -1 # j = i –1 L2: slti $t0, $s1, 0 # $t0 = 1, if j <0 bne $t0, $zero, exit2 # if j <0 go to exit2 add $t1, $s1, $s1 # $t1 = 2 * j add $t1, $t1, $t1 # $t1 = 4 * j add $t2, $s2, $t1 # $t2 = v + (4 *j) lw $t3, 0 ( $t2) # $t3 = v[ j ] lw $t4, 4 ( $t2) # $t4 = v[ j + 1] slt $t0, $t4, $t3 # $t0 = 1, if v[j+1]<v[j] beq $t0, $zero, exit2 # if v[j+1]>=v[j] goto exit2

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); add $a0, $s2,$zero # $a0 = v add $a1, $s1, $zero # $a1 = j jal swap # call swap routine

Inner Loop $s0=i, $s1=j, $s2=v, $s3=n for ( j = i -1; j >= 0 && v[ j ] > v[ j + 1 ]; j = j - 1) { swap ( v, j ); add $a0, $s2,$zero # $a0 = v add $a1, $s1, $zero # $a1 = j jal swap # call swap routine addi $s1, $s1, -1 # j = j – 1 j L2

sort : addi $sp, $sp, -20 # move stack pointer sw $ra, 16 ($sp) # save $ra on stack sw $s3, 12 ($sp) # save $s3 on stack sw $s2, 8 ($sp) # save $s2 on stack sw $s1, 4 ($sp) # save $s1 on stack sw $s0, 0 ($sp) # save $s0 on stack add $s2, $a0, $zero # $s2 = $a0 = v base add $s3, $a1, $zero # $s3 = $a1 = n Procedure Body exit1: lw $s0, 0 ($sp) # restore $s0 from stack lw $s1, 4 ($sp) # restore $s1 from stack lw $s2, 8 ($sp) # restore $s2 from stack lw $s3, 12 ($sp) # restore $s3 from stack lw $ra, 16 ($sp) # restore $ra from stack addi $sp, $sp, 20 # restore stack pointer jr $ra # return

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, exit1 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: ( PC + 4 ) + ( address * 4 ) beq $t0, $zero, exit1 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: ( 80044 ) + ( address * 4 ) = 80112 beq $t0, $zero, exit1 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: ( address * 4 ) = 68 beq $t0, $zero, exit1 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 ( PC + 4 ) + ( ? * 4 ) bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 80056 + ( ? * 4 )=80104 bne $t0, $zero, exit2 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 (? * 4 ) = 48 bne $t0, $zero, 12 6 instructions beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions ( PC + 4 ) + ( ? * 4 ) beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions 80084 + ( ? * 4 )=80104 beq $t0, $zero, exit2 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions ( ? * 4 ) = 20 beq $t0, $zero, 5 4 instructions j L2 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions beq $t0, $zero, 5 4 instructions j L2 address * 4 = 80048 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions beq $t0, $zero, 5 4 instructions j 20012 address * 4 = 80048 80104 exit2: addi $s0, $s0, 1 j L1 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions beq $t0, $zero, 5 4 instructions j 20012 80104 exit2: addi $s0, $s0, 1 j L1 ? * 4 = 80036 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions beq $t0, $zero, 5 4 instructions j 20012 80104 exit2: addi $s0, $s0, 1 j 20009 ? * 4 = 80036 80112 exit1: lw $s0, 0 ($sp)

Look at Addresses 80000 sort: 8 instructions 80036 L1: beq $t0, $zero, 17 1 instruction 80048 L2: slti $t0, $s1, 0 bne $t0, $zero, 12 6 instructions beq $t0, $zero, 5 4 instructions j 20012 80104 exit2: addi $s0, $s0, 1 j 20009 80112 exit1: lw $s0, 0 ($sp)