Please below solution, let me know if you have any query.
=========================================================================
prompt_lower: .asciiz "enter lower bound:"
prompt_upper: .asciiz "enter upper bound:"
prompt_size: .asciiz "enter step size:"
end_prompt: .asciiz "Would you like to run another calculation? (0
to No, 1 to Yes) "
bound_error: .asciiz "You have enter lower bound which was greater
than the upper bound. \n"
step_size_wrn:.asciiz "A step size lower than 0.1 is not
recommended due to lack of required precision with floats, Would
you like to continue or re-enter your inputs? (0 to Continue, 1 to
Re-enter)"
main:
# lower bound in $f7
# upper bound in $f8
# step size in $f9
# lower bound input
la $a0, prompt_lower
li $v0, 4
syscall
li $v0, 6
syscall
# save value
mov.s $f7, $f0
# upper bound input
la $a0, prompt_upper
li $v0, 4
syscall
li $v0, 6
syscall
# save value
mov.s $f8, $f0
# to check lower bound <= upper bound
c.le.s $f7, $f8
bc1f wrong_input
# Step size input
la $a0, prompt_size
li $v0, 4
syscall
li $v0, 6
syscall
# save value
mov.s $f9, $f0
# step size check for lower than 0.1
l.s $f10, precision
c.lt.s $f9, $f10
bc1t prec_warning
# user interface
prepare_main:
# print spacing lines
la $a0, lines
li $v0, 4
syscall
# print header
la $a0, header
li $v0, 4
syscall
# print spacing lines
la $a0, lines
li $v0, 4
syscall
# printing the requested values by loop
loop_main:
# stop the loop if lower bound register value is not less than or
equal upper bound value
c.lt.s $f7, $f8
bc1f ret_main
# lower bound to the screen
mov.s $f12, $f7
li $v0, 2
syscall
# tab seperator
la $a0, tab
li $v0, 4
syscall
# load current lower bound value
mov.s $f0, $f7
# calculate exp
jal exp
# current value to the console
li $v0, 2
syscall
# tab seperator
la $a0, tab
li $v0, 4
syscall
# reload current the lower bound value into argument
register
mov.s $f0, $f7
# calculate ln
jal ln
# ln current value to the console
li $v0, 2
syscall
# increment lower bound value by one
add.s $f7, $f7, $f9
la $a0, new_line
li $v0, 4
syscall
j loop_main
# notify user about if incorrect input regarding the bounds
wrong_input:
# print error message
la $a0, bound_error
li $v0, 4
syscall
j main
# notify user about potential accuracy lost when choosing step
sizes below 0.1
prec_warning:
la $a0, step_size_wrn
li $v0, 4
syscall
li $v0, 5
syscall
# if 1, repeat program, if 0, continue
bne $v0, $zero, main
j prepare_main
ret_main:
# print spacing lines
la $a0, lines
li $v0, 4
syscall
# print end message
la $a0, end_prompt
li $v0, 4
syscall
# read user input
li $v0, 5
syscall
# if 1, repeat program, if 0, end program
bne $v0, $zero, main
la $a0, goodbye
li $v0, 4
syscall
li $v0, 10
syscall
.end main
exp:
# argument x in $f0
# variable nom in $f1
# variable den in $f2
# loop variable i (int) in $t0
# loop condition variable in $t1
# return variable sum in $f12
# loop variable i (float) in $f3
# i-th summand in $f4
# lower bound in $f29
# upper bound in $f30
l.s $f29, exp_lower_bound
l.s $f30, exp_upper_bound
c.lt.s $f0, $f29
bc1t exp_out_of_bounds
c.le.s $f0, $f30
bc1f exp_out_of_bounds
# initialize nom and den with 1.0
li.s $f1, 1.0
li.s $f2, 1.0
# set initial value for sum
li.s $f12, 1.0
# set loop variables
li $t0, 1
li $t1, 20
# loop to concatenate summands
loop_exp:
# leave loop if loop variable has become larger than loop condition
variable
bgt $t0, $t1, ret_exp
# calculate new nominator: nom = nom * x
mul.s $f1, $f1, $f0
# calculate new denominator: den = den * i
mtc1 $t0, $f3
cvt.s.w $f3, $f3 # convert i into float
mul.s $f2, $f2, $f3
# calculate i-th summand
div.s $f4, $f1, $f2
# append i-th summand to the total sum
add.s $f12, $f12, $f4
# increment loop variable i
addi $t0, $t0, 1
j loop_exp
# set error value if argument is out of bounds
exp_out_of_bounds:
li.s $f12, -1.0
# exit point when end of loop is reached
ret_exp:
jr $ra
.end exp
ln0:
# argument x in $f0
# variable nom in $f1
# variable den in $f2
# quotient nom / den in $f3
# i-th summand in $f4
# variable sign (float) in $f5
# value (x - 1) in $f6
# constant -1.0 in $f13
# variable sign in $t0
# constant -1 in $t1
# loop variable i in $t2
# loop condition in $t3
# return variable sum in $f12
# initialize constants:
li.s $f13, -1.0
li $t1, -1
# initialize nom with value x - 1.0
add.s $f1, $f0, $f13
mov.s $f6, $f1 # save value for later
# initialize den with 1.0
li.s $f2, 1.0
# initialize sign variable positively
li $t0, 1
# make first summand returnable in case loop is not used
mov.s $f12, $f1
# set loop variables
li $t2, 1
li $t3, 250
# loop to concatenate summands
loop_ln0:
# leave loop if loop variable has become larger than loop condition
variable
bgt $t2, $t3, ret_ln0
# calculate i-th nominator: nom = nom * (x - 1)
mul.s $f1, $f1, $f6
# calculate i-th denominator: den = den + 1
sub.s $f2, $f2, $f13 # den + 1 == den - (-1)
# invert sign variable
mul $t0, $t0, $t1
# calculate i-th (nom / den)
div.s $f3, $f1, $f2
# multiply (nom / den) with i-th sign -> determine i-th
summand
mtc1 $t0, $f5
cvt.s.w $f5, $f5 # convert i-th sign integer to float
mul.s $f4, $f3, $f5
# append i-th summand to the total sum
add.s $f12, $f12, $f4
# increment loop variable
addi $t2, $t2, 1
j loop_ln0
# exit point when end of loop is reached
ret_ln0:
jr $ra
.end ln0
ln:
# argument x in $f0
# variable ln(x) in $f1
# variable b (float) in $f2
# constant 2.0 in $f3
# constant ln(2) in $f4
# value b * ln(2) in $f5
# variable b (int) in $t4
# return variable sum in $f12
# lower bound in $f31
l.s $f31, ln_lower_bound
c.le.s $f0, $f31
bc1t ln_out_of_bounds
# initialize constant values
li.s $f3, 2.0
# initialize b with value 0
li $t4, 0
# loop for splitting x into a * 2^b
loop_ln:
# stop the loop if a has become less or equal the value of
2.0
c.le.s $f0, $f3
bc1t fin_ln
# divide x by 2
div.s $f0, $f0, $f3
# increment b
addi $t4, $t4, 1
j loop_ln
# exit point when end of loop is reached
fin_ln:
# calculate ln(x) (x* = x/2^n * 2^n)
addi $sp, $sp, -4
sw $ra, 0($sp)
jal ln0
# reinitialize constants
li.s $f3, 2.0
li.s $f4, 0.6931464
# calculate product b * ln(2)
mtc1 $t4, $f2
cvt.s.w $f2, $f2 # convert interger variable b into float
mul.s $f5, $f2, $f4
# calculate final sum
add.s $f12, $f12, $f5
lw $ra, 0($sp)
addi, $sp, $sp, 4
j ret_ln
# set error value if argument is out of bounds
ln_out_of_bounds:
li.s $f12, -1.0
# exit point when calculation of ln(x) is reached.
ret_ln:
jr $ra
.end ln
IN MIPS ASSEMBLY, computer Taylor series for ex. Program should compute until x^4/4! Example: Input 2...
Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)
Use in MATLab (b) Write a computer program to calculate ex as an approximate series summation, to an accuracy of 1010. The value of x should be supplied to the program with the "input" command. Do not run the program. (b) Write a computer program to calculate ex as an approximate series summation, to an accuracy of 1010. The value of x should be supplied to the program with the "input" command. Do not run the program.
Goal is to find nth Fibonacci number. Indexing needs to start at 0. The program has to look like the example and I am having trouble programing something that willwork. Also, it must ask if the user would like to find another number at the end. Can someone please help?!? It must be in MIPS assembly programing, not Java.Example:Which Fibonacci number do you want: 7Output: Number is 13 and the series is 0, 1, 1, 2, 3, 5, 8, 13Do...
This is the given code: /** * This program uses a Taylor Series to compute a value * of sine. * */ #include<stdlib.h> #include<stdio.h> #include<math.h> /** * A function to compute the factorial function, n!. */ long factorial(int n) { long result = 1, i; for(i=2; i<=n; i++) { result *= i; } return result; } int main(int argc, char **argv) { if(argc != 3) { fprintf(stderr, "Usage: %s x n ", argv[0]); exit(1); } double x = atof(argv[1]); int...
Write and test a MIPS assembly language program to compute and display the first prime numbers up to n where n is given. Set n to be 19 but the program should work of any value of n. For the program to identify primes, the easiest way is to use the algorithm: for (i = 2; i < x; i++) if ((x % i) == 0) break; //break out, not prime where x is the number you are checking...
**URGENT** Please help with this MIPS program? (calculator program that uses values from a user's input file and solves them; needs order of operations) Write a MIPS Assembly Language program to read hexadecimal values and operations (one per line) from a file. The file name should be requested and read in from the console. Once the ascii number has been read in, convert it to internal, binary, storage (decimal). The input format may be either fixed-format, 32-bit, twos compliment values,...
(1 point) Taylor Series: Compute the Taylor Series below. WebWork does not understand factorials, so you will need to enter numerical values. For example, enter "1/6" instead of "1/3!". You may also need to enter coefficients 0 or 1. (a) el = x+ (b) cos? x = (c)x= + () 42+ + 32° +222 +2+1= (x - 1)+ + (x − 1)2+ (x - 1)+ (x 1)3+ (x 1)2+ (x - 1)4 + .... (x - 1)3+ (x - 1)
using mips for assembly language WPte a program that asks the user for 2 numbers. the program should then add the 2 numbers bit by bit, using boolean operators no arithmetic operations ex: add, addi, sub, mult, div or arrays are permitted in this project. forming a new variable (in a register) with the solution. That solution is to be output bit by bit using the function that was written in class do not use syscall with a value 10...
Setup a program that will solve for sin x using the Taylor series expansion of x. Make sure the number of terms is some type of input. Calculate approximate 1. error Setup a program that will solve for sin x using the Taylor series expansion of x. Make sure the number of terms is some type of input. Calculate approximate 1. error
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...