Concept explainers
I need help please to modify this code so that it will not use li.s and li.d because my current compiler does not support those instructions in MIPS assembly
.data
prompt1: .asciiz "Enter the number of real numbers: "
prompt2: .asciiz "Enter a real number: "
result: .asciiz "The average is: "
.text
.globl main
main:
# Prompt for the number of real numbers
li $v0, 4
la $a0, prompt1
syscall
li $v0, 5 # Read integer
syscall
move $t0, $v0 # Number of real numbers
move $t1, $zero # Counter for input numbers
# Initialize floating-point sum to 0.0
li.s $f0, 0.0 # Initialize sum in floating-point register
input_loop:
beq $t1, $t0, calculate # If counter equals input count, go to calculate
# Prompt for each real number
li $v0, 4
la $a0, prompt2
syscall
li $v0, 6 # Read float
syscall
# Add input to sum
add.s $f0, $f0, $f12 # Update sum (add the new input)
addi $t1, $t1, 1 # Increment counter
j input_loop
calculate:
# Calculate the average
mtc1 $t0, $f2 # Move the count into $f2
cvt.s.w $f2, $f2 # Convert the integer count to float
div.s $f4, $f0, $f2 # Average = sum / count
to generate a solution
a solution
- Please run this on linux, compile and look at the placement for row "Tangent". Match the numbers below tangent and make sure all the other row numbers are lining up with the other headings main.c #include <stdio.h>#include <math.h> #define M_PI 3.14159265358979323846 /** * Given a incrementVal value, this function will print a table of trigonometric values * from 0 to 360, in increments of the incrementVal value. * For example, if the incrementVal value is 90, the table will print values for 0, 90, 180, 270 and 360. * incrementVal - the degree value to use for the increment*/void displayTriTab(int incrementVal) { //Display the header for the table printf("\n\t--- TRIGONOMETRIC TABLE ---\n\n"); // Display the column headings for the table printf("%3s%10s%10s%10s%10s\n", "Degrees", "Radians", "sine", "cosine", "tangent"); printf("%3s%10s%10s%10s%10s\n", "-------", "-------", "------", "-------", "-------"); //Declare variables for radians, sine cosine,…arrow_forwardMy assembly code is having an error in Jdoddle's online assembly compiler. Please tell me whats wrong so I can keep that in mind. Thanks!---- global _mainextern _printfextern _scanf section .data message1 db "Enter first number: ", 0message message2 db "Enter second number:", formatIn db '%d', 0 formatOut db '%d', 10, 0 show db "Sum: ", 0 section .bss firstInt resb 4 secondInt resb 4 section .text_main: push message1 call _printf pop eax push firstInt push formatIn call _scanf pop eax pop eax push message2 call _printf pop eax push secondInt push formatIn call _scanf pop eax pop eax push show call _printf pop eax mov ebx, dword [firstInt] mov ebx, dword [secondInt] add ebx, ecx, push ebx push formatOut call _printfarrow_forwardThis is warning you, don't use any AI platform to generate answer.arrow_forward
- Python Programming- Computer-Assisted Instruction Part 1: Computer-Assisted Instruction (CAI) refers to the use of computers in education. Write a script to help an elementary school student learn multiplication. Create a function that randomly generates and returns a tuple of two positive one-digit integers. Use that function's result in your script to prompt the user with a question, such as: How much is 6 times 7? For a correct answer, display the message "Very good!" and ask another multiplication question. For an incorrect answer, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. Part 2: Varying the computer's responses can help hold the student's attention. Modify the program so that various comments are displayed for each answer. Possible responses to a correct answer should include 'Very good!' , 'Nice work!' and 'Keep up the good work!' Possible responses to an incorrect answer shojld…arrow_forward#python def add_func(a,b): print(f"add_func output for 1 + 2: {add_func(1, 2)}") print(f"add_func output for good + day: {add_func('good',' day')}") (add_func(1,2) = 3, (add_func('good',' day') = "good day"arrow_forwardWrite nested for loops to print the following pattern, as shown in the picture.arrow_forward
- Complete the Python function given below: def computeExp(x): #returns the value of x* + 2x - 5x² + 6arrow_forwardin C++: Given a decimal number, your code must convert the decimal number into binary, and insert the three necessary check bits that validate it as being correctly assembled and received. Please display the following results: -1 The Original Decimal Number -2 The Correct Form of the resulting Hamming Code 1: 15 2: 7 3: 12 4: 2 5: 6arrow_forwardArt.java In this part you will create a program Art.java that produces a recursive drawing of the design attached in the picture. Requirements Art.java must take one (1) integer command-line argument n that controls the depth of recursion. Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.) You may not change the size of the drawing window (but you may change the scale). Do not add sound. Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions. Optionally, you may use the Transform2D library you implemented in Part 1. You may also define additional geometric transforms in Art.java, such as sheer, reflect across the x- or y- axis, or rotate about an arbitrary point (as opposed to the origin). Your program must be organized into at least three separate functions, including main(). All functions except main() must be private. call…arrow_forward
- # python Date = [ { "createdAt": "2022-05-23T18:09:37", "balance": 1000000 }, { "createdAt": "2022-05-23T14:18:39", "balance": 1000000 }, { "createdAt": "2022-05-23T11:43:55", "balance": 90 }, { "createdAt": "2022-05-18T12:18:33", "balance": 2000000 }, { "createdAt": "2022-05-18T12:17:58", "balance": 10000000 }, { "createdAt": "2022-05-10T12:08:10", "balance": 79086 }, { "createdAt": "2022-05-10T12:07:14", "balance": 1111 }, { "createdAt": "2022-05-02T11:28:03", "balance": 13200 }, { "createdAt": "2022-04-21T11:47:08", "balance": 3000 }, { "createdAt": "2022-04-21T11:46:16", "balance": 6800 }, { "createdAt": "2022-04-21T11:33:26", "balance": 6000 }, { "createdAt": "2022-04-21T11:22:37", "balance": 5000 }, { "createdAt": "2022-04-21T11:21:48", "balance": 8000 }, { "createdAt": "2022-04-21T11:18:39", "balance": 7000 } ] # desire output [ { "createdAt": "2022-05-23", "balance": 2000090 }, { "createdAt": "2022-05-18", "balance": 12000000 }, { "createdAt": "2022-05-10", "balance": 80197…arrow_forwardTask: A shop sells a range of mobile devices, SIM cards and accessories as shown in the table (see screenshot): Write a program algorithm for this shop. - Your program or programs must include appropriate prompts for the entry of data; data must be validated on entry. - Error messages and other output need to be set out clearly and understandably. - All arrays, variables, constants and other identifiers must have meaningful names. You will need to complete these three tasks. Task 1 – Setting up the system. Write a program to: - use appropriate data structures to store the item code, description and price information for the mobile devices, SIM cards and accessories; - allow the customer to choose a specific phone or tablet; - allow phone customers to choose whether the phone will be SIM Free or Pay As You Go; - allow the customer to choose a standard or luxury case; - allow the customer to choose the chargers required (none,…arrow_forwardC++ Code: This function will print out the information that has been previously read (using the function readData) in a format that aligns an individual's STR counts along a column. For example, the output for the above input will be: name Alice Bob Charlie ---------------------------------------- AGAT 5 3 6 AATG 2 7 1 TATC 8 4 5 This output uses text manipulators to left-align each name and counts within 10 characters. The row of dashes is set to 40 characters. /** * Computes the longest consecutive occurrences of several STRs in a DNA sequence * * @param sequence a DNA sequence of an individual * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @returns the count of the longest consecutive occurrences of each STR in nameSTRs **/ vector<int> getSTRcounts(string& sequence, vector<string>& nameSTRs) For example, if the sequence is AACCCTGCGCGCGCGCGATCTATCTATCTATCTATCCAGCATTAGCTAGCATCAAGATAGATAGATGAATTTCGAAATGAATGAATGAATGAATGAATGAATG and the vector namesSTRs is…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,