Question

In: Computer Science

How can I write a simple MIPS program to print out the following elements of an...

How can I write a simple MIPS program to print out the following elements of an array of the size of 10: 5,10,15,20,25,30,35,40,45,50

Solutions

Expert Solution


Given below is the code for the question. Please do rate the answer if it helped. Thank you.

.data
   arr: .word 5,10,15,20,25,30,35,40,45,50
   blank: .asciiz " "
.text
main:
   #load address of arr into $t0
   la $t0, arr

   #(index = $t1) initialize index to 0
   li $t1, 0
loop:
   bge $t1, 10, endloop #while index < 10
   #load current element into $a0 for printing
   lw $a0, ($t0)
   li $v0, 1 #syscall for printing int
   syscall
  
   #print a space for separation
   li $v0, 4
   la $a0, blank
   syscall
  
   #update variables for next iteration
   add $t1, $t1, 1
   add $t0, $t0, 4 #each int takes 4 bytes, so next element is 4 bytes away from current address
   b loop

endloop:
   #end program
   li $v0, 10
   syscall
  
  

output
-----
5 10 15 20 25 30 35 40 45 50
-- program is finished running --


Related Solutions

Write a MIPS assembly program that calculates the sum of all the elements in the following...
Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}
Hello, How can I make the program print out "Invalid data!!" if the file has a...
Hello, How can I make the program print out "Invalid data!!" if the file has a grade that is not an A, B, C, D, E, or F or a percentage below zero. The program should sort a file containing data about students like this for five columns: one for last name, one for first name, one for student ID, one for student grade percentage, one for student grade. Smith Kelly 438975 98.6 A Johnson Gus 210498 72.4 C Reges...
write a mips program to find the number of elements of the array that are divisible...
write a mips program to find the number of elements of the array that are divisible by 3.
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
How do I write a program in MIPS that will change all the characters in a...
How do I write a program in MIPS that will change all the characters in a string into lowercase. For instance: string: " CANBERRA AUSTRALIA" Output: "canberra australia"
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
write a MIPS program to ask user to input the number of elements of array
write a MIPS program to ask user to input the number of elements of array
How would i write a MIPS program that converts 2 decimals to binary
How would i write a MIPS program that converts 2 decimals to binary
I need a MIPS Assembly program that "Display the elements of the linked list in reverse...
I need a MIPS Assembly program that "Display the elements of the linked list in reverse order." It needs subprogram and those subprogram does not have t registers.
Write a complete Java program to print out the name bob
Write a complete Java program to print out the name bob
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT