1 / 6

CDA 3100

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

hagen
Télécharger la présentation

CDA 3100

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CDA 3100 Recitation Week 15

  2. 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

  3. 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]

  4. 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

  5. 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

  6. ??? Microsoft Office Libre Office

More Related