Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to program something in MIPS assembly that will compute the union of two integer arrays (only unique values). Here is my code

I am trying to program something in MIPS assembly that will compute the union of two integer arrays (only unique values). Here is my code so far, but I don't understand what I am really doing. It seems like my loop isn't working. I could easily do this in C, Python, or Matlab but I can't get anything done with MIPS. Can someone give me a walk through with correct language for the program? I understand the thought process but not how to implement it.

MY THOUGHT PROCESS: have the arrays in different registers, then compare numbers in both registers and if they're different, move them to the results register.

image text in transcribed

1 This program computes the union of two ten element sets of integers .data arrA: word 243, -459, 826, -535, 264, 698, 268, 281, 921, 886 arrayB: .word 864, 281, 781, 698, -535, 128, 886, 336, 799, 826 Result: .alloc 20 # ALso, for Hill (only), do not write values to registers $8, $29, $30, or $31 10 .text 11 # write your code here 12 13 15 16 17 18 19 20 21 li $1,10 #1:0 li $2,0 #counter -9 addi $14,$0,0 #offsetA-8 addi $15,$0,0 #offset8-e lw $3, arrA($3) lw $4, arrB($4) beq $2,$1,end # if $1 lw $5, arrA($14) 1w $6, arrB ($15) bne $5,$6, $20 addi $1, $1, 1 # add 1 to $1 j loop # jump back to the top loop: "10 end it # current element in arrA 23 24 25 26

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions