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

Assignment Description: An array of integers can be assigned to a memory address

ID: 668259 • Letter: A

Question

Assignment Description:

An array of integers can be assigned to a memory address in the .data section of a MIPS assembly language program as show below. Here the length of the array is stored first, and then the elements of the array numbers next. A C program that will ask a user to enter two integers and compute the sum of numbers in the array that are between those two integers (inclusive). Implement a MIPS assembly language program to compute the sum of numbers in the array that are between the entered integers. If your program causes an infinite loop, press Control and 'C'keys at the same time to stop it.

   .data

numbers_len:         .word     14
numbers:             .word     11, 24, 3, -6, 14, -18, 21, 45, 12, -27, 35, -7, 44, -28

The following shows how it looks like in a C program:

write it by Mips assemble

Thanks

Explanation / Answer

data space: .asciiz " " X: .word 11, 24, 3, -6, 14, -18, 21, 45, 12, -27, 35, -7, 44, -28 N: .word 10 .text main: la $a0, X #$a0=load address of array X lw $a1, N #$a1=10 --number elements jal readArray #call readArray li $v0, 10 #exit program syscall readArray: li $t0, 0 #$t0=0 li $t1, 0 #$t1=0 buc: bge $t0, $a1, final #if $t0 >= $a1 then goto final lw $a0, X($t1) #$a0 = X(i) li $v0, 1 #Print integer syscall la $a0, space #load a space: " " li $v0, 4 #print string syscall addi $t1, $t1, 4 #Every 4 bytes there is an integer in the array addi $t0, $t0, 1 #$t0=$t0+1 b buc #goto buc final: jr $ra #return

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