60 likes | 167 Views
CDA 3100. Recitation Week 15. What does the function f1 do:. .data A: .word 10,21,45,8,100,15,29,12,3,19 B: .word 2,5,33,5,20,1,53,52,5,5 C: .word 6,8,5,4,5,22,53,12,33,89 . text . globl main main: la $a0, A la $a1, B la $a2, C li $a3, 10 jal f1 li $v0,10 #exit syscall
E N D
CDA 3100 Recitation Week 15
What does the function f1 do: .data A: .word 10,21,45,8,100,15,29,12,3,19 B: .word 2,5,33,5,20,1,53,52,5,5 C: .word 6,8,5,4,5,22,53,12,33,89 .text .globl main main: la $a0, A la $a1, B la $a2, C li $a3, 10 jalf1 li $v0,10 #exit syscall f1: li $v0, -1 ble $a3, $0, L3 li $t7, 0 L1: lw $t0, 0($a0) lw $t1, 0($a1) lw $t2, 0($a2) sub $t0, $t0, $t1 blt $t0, $t2, L2 addi $a0, $a0, 4 addi $a1, $a1, 4 addi $a2, $a2, 4 addi $t7, $t7, 1 blt $t7, $a3, L1 j L3 L2: addi $v0,$t7,0 L3: jr $ra
What does the function f1 do: .data A: .word 10,21,45,8,100,15,29,12,3,19 B: .word 2,5,33,5,20,1,53,52,5,5 C: .word 6,8,5,4,5,22,53,12,33,89 .text .globl main main: la $a0, A la $a1, B la $a2, C li $a3, 10 jalf1 li $v0,10 #exit syscall f1: li $v0, -1 ble $a3, $0, L3 li $t7, 0 L1: lw $t0, 0($a0) lw $t1, 0($a1) lw $t2, 0($a2) sub $t0, $t0, $t1 blt $t0, $t2, L2 addi $a0, $a0, 4 addi $a1, $a1, 4 addi $a2, $a2, 4 addi $t7, $t7, 1 blt $t7, $a3, L1 j L3 L2: addi $v0,$t7,0 L3: jr $ra It finds the first i such that A[i] – B[i] < C[i]
What does f1 return in $v0: .data A: .word 10,21,45,8,100,15,29,12,3,19 B: .word 2,5,33,5,20,1,53,52,5,5 C: .word 6,8,5,4,5,22,53,12,33,89 .text .globl main main: la $a0, A la $a1, B la $a2, C li $a3, 10 jalf1 li $v0,10 #exit syscall f1: li $v0, -1 ble $a3, $0, L3 li $t7, 0 L1: lw $t0, 0($a0) lw $t1, 0($a1) lw $t2, 0($a2) sub $t0, $t0, $t1 blt $t0, $t2, L2 addi $a0, $a0, 4 addi $a1, $a1, 4 addi $a2, $a2, 4 addi $t7, $t7, 1 blt $t7, $a3, L1 j L3 L2: addi $v0,$t7,0 L3: jr $ra
What does f1 return in $v0: .data A: .word 10,21,45,8,100,15,29,12,3,19 B: .word 2,5,33,5,20,1,53,52,5,5 C: .word 6,8,5,4,5,22,53,12,33,89 .text .globl main main: la $a0, A la $a1, B la $a2, C li $a3, 10 jalf1 li $v0,10 #exit syscall f1: li $v0, -1 ble $a3, $0, L3 li $t7, 0 L1: lw $t0, 0($a0) lw $t1, 0($a1) lw $t2, 0($a2) sub $t0, $t0, $t1 blt $t0, $t2, L2 addi $a0, $a0, 4 addi $a1, $a1, 4 addi $a2, $a2, 4 addi $t7, $t7, 1 blt $t7, $a3, L1 j L3 L2: addi $v0,$t7,0 L3: jr $ra 3
??? Microsoft Office Libre Office