
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Solutions to various exercises from cs 271 homework 2, including exercises related to array comparison and addressing in mips assembly language. The document also discusses a limitation of pc-relative addressing and a potential solution.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!
sll $t0, $t3, 9 # shift $t3 left by 9, store in $t srl $t0, $t0, 15 # shift $t0 right by 15
sll $a2, $a2, 2 # max i= 2500 * 4 sll $a3, $a3, 2 # max j= 2500 * 4 add $v0, $zero, $zero # $v0 = 0 add $t0, $zero, $zero # i = 0 outer: add $t4, $a0, $t0 # $t4 = address of array 1[i] lw $t4, 0($t4) # $t4 = array 1[i] add $t1, $zero, $zero # j = 0 inner: add $t3, $a1, $t1 # $t3 = address of array 2[j] lw $t3, 0($t3) # $t3 = array 2[j] bne $t3, $t4, skip # if (array 1[i] != array 2[j]) skip $v0++ addi $v0, $v0, 1 # $v0++ skip: addi $t1, $t1, 4 # j++ bne $t1, $a3, inner # loop if j != 2500 * 4 addi $t0, $t0, 4 # i++ bne $t0, $a2, outer # loop if i != 2500 * 4
here: bne $s0, $s2, skip j there skip: … there: add $s0, $s0, $s