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

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.
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
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an...
ONLY IN C LANGUAGE Write a C program to print all the unique elements of an array. Print all unique elements of an array Enter the number of elements to be stored in the array: 4 Input 4 elements in the arrangement: element [0]: 3 element [1]: 2 element [2]: 2 element [3]: 5 Expected output: The only items found in the array are: 3 5
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT