Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly code that declare three arrays A,B,C where the value of array

ID: 3700870 • Letter: W

Question

Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ?
Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ?
Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ?

Explanation / Answer

.data

array_a: .space 20

array_b: .space 20

array_c: .space 20

msg_a: .asciiz "Enter 5 elements for array a :"

msg_b: .asciiz "Enter 5 elements for array b :"

msg_c: .asciiz "The 5 elements for array c :"

.text

main:

la $s0,array_a

la $s1,array_b

la $s2,array_c

li $t0,5

li $t1,0

li $v0,4

la $a0,msg_a

syscall

init_a:

beq $t1,$t0,init_a_done

li $v0,5

syscall

move $t2,$v0

sw $t2,0($s0)

addi $s0,$s0,4

addi $t1,$t1,1

b init_a

init_a_done:

li $t0,5

li $t1,0

li $v0,4

la $a0,msg_b

syscall

init_b:

beq $t1,$t0,init_b_done

li $v0,5

syscall

move $t2,$v0

sw $t2,0($s1)

addi $s1,$s1,4

addi $t1,$t1,1

b init_b

init_b_done:

li $t0,5

li $t1,0

init_c:

beq $t1,$t0,init_c_done

lw $t3,0($s0)

lw $t4,0($s1)

slt $t5,$t4,$t3

beq $t5,$0,IF_COND

mult $t2,$t3,$t4

b store_element

IF_COND:

sub $t2,$t3,$t4

store_element:

sw $t2,0($s2)

addi $s2,$s2,4

addi $s1,$s1,4

addi $s0,$s0,4

addi $t1,$t1,1

b init_c

init_c_done:

li $v0,10

syscall

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote