I need help with this code please its supposed to take 'n' numbers and take the average of all of the numbers in MIps assembly code
the problem is that it is not working
here is the code:
.data
prompt: .asciiz "Enter the number of real numbers: "
.text
.globl main
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
move $t0, $v0
li $t1, 0
loop:
beq $t0, $t1, end
li $v0, 6
syscall
addi $t1, $t1, 1
j loop
end:
li $v0, 10
syscall
# Initialize $t0 to hold the sum
add $t0, $zero, $zero
# Initialize $t1 to hold the count
add $t1, $zero, $zero
# Start the loop
loop2:
# Load the current number
lw $t2, 0($a0)
# Add the current number to the sum
add $t0, $t0, $t2
# Increment the counter
addi $t1, $t1, 1
# Move to the next number
addi $a0, $a0, 4
# Continue the loop if there are more numbers
bne $t1, $a1, loop2
# Calculate the average
div $t0, $t1
# Move the result to $v0
, mflo $v0
Step by stepSolved in 2 steps
- Hi, I need help writing bit-wise operations in java. I am new to java so I am struggling with the syntax.arrow_forwardTake a look at the following assembly code. Which of the following describes what is going on in the code? MOVQ $0 , %raxmystery: INCQ %rax CMPQ $5 , %rax JL mystery Group of answer choices A. This is a function call to the function 'mystery' where we increment the value stored in rax. B. This is essentially a while loop decreasing a counter by 1. C. First 0 is stored in a register--rax. Then we increment rax by 1, and compare to see if the value is 5. If it is less than 5, then we jump back to the label mystery. This is essentially a while loop incrementing a counter by 1.arrow_forwardWrite an ARM program include comments for explanation thanks.; Assume that there are two IEEE-754 single precision floating point numbers stored in my_data.; Calculate the sum of these two numbers and store it in R8; Your program's results should be same as/similar to what happens in real C/Java programs. ; Suggestion: write functions that can extract the sign bit, mantissa and exponentmy_data DCD 0xC0350000, 0x40310000arrow_forward
- I need help in a C++ program. I'm not sure what to do add next. Text files: roomset_one.dat 426 25 25327 18 14420 20 15317 100 101−1 −1 −1 roomset_two.dat 55 10 5102 12 10111 15 16250 20 254033 500 2077810 800 8008810 800 0-2 -2 -2 roomset_three.dat -999 Program Requirements DO NOT open the file and use it within your program (input redirection) Example of input redirection: ./a.out < roomset_one.dat You must include the following functions: ReadRoomData: a void function that accepts three reference parameters (the room number, max capacity, and enrolled). It should read in all three values from stdin. DetermineStatus: a value-returning function that has one parameter (available enrollment). It should return a std::string containing the status of the room (OPEN, FULL, OVER) OutputRoomInfo: a void function that accepts three value parameters (room, max capacity, and enrolled). It should call DetermineStatus and output the formatted room information for that single…arrow_forwardWrite a quick program in C-64 BASIC that will create a variable, and assign it with the decimal value ‘63’. The program will add ‘1’ to this variable and print the result, all in BASIC. The 2nd part of this program is to do the entire program using Assembly. Load it into $0800 and from the C64 prompt, use the ‘sys’ command to run it. You don’t have to output the result to the screen, instead, store the result in location $0840.arrow_forwardWith the aid of c++, write a code which utitilizes a random number generator to generate a 2 digits +(positive) integer. The user is permitted to do the operations listed below using the above knowledge.i.Reverse the digits of the randomly generated number ii.Double the randomly generated number iii.Add up(sum) the digits of the randomly generated number iv.Also check if the randomly generated number is a prime after each operation.Note the following below In case the randomly generated number is less than 10 after performing the above operation add 10 to the itarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education