Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

.data prompt: .asciiz Enter range (in yards): tflight: .asciiz Time of flight: hmax: .asciiz Maximum height: theta: .asciiz Angle trajectory: newline:

.data

prompt: .asciiz "Enter range (in yards): "

tflight: .asciiz "Time of flight: "

hmax: .asciiz "Maximum height: "

theta: .asciiz "Angle trajectory: "

newline: .asciiz " "

space: .asciiz " "

range: .word 0

.text

.globl main

main:

# print prompt and get user input for range

li $v0, 4 # print string syscall

la $a0, prompt

syscall

li $v0, 5 # read integer syscall

syscall

sw $v0, range

# calculate time-of-flight

lw $t0, range

li $t1, 2500

li $t2, 32.2

li $t3, 3600

mul $t4, $t0, $t3

div $t5, $t4, $t1

# perform taylor series expansion for arcsin

# set initial values

li $t6, 0 # x = 0

li $t7, 1 # k! = 1

li $t8, 1 # counter = 1

# start loop

TaylorLoop:

# calculate x^2

mul $t9, $t6, $t6

# calculate x^2k

mul $t10, $t9, $t6

# calculate (2k - 1)!!

mul $t11, $t7, $t8

# calculate (2k - 1)!! * x^2k

mul $t12, $t10, $t11

# calculate (2k - 1)!! * x^2k / (2k)!

div $t13, $t12, $t7

# add to sum

add $t14, $t14, $t13

# increment counter

addi $t8, $t8, 1

# multiply counter by 2

mul $t15, $t8, 2

# update value of k!

mul $t7, $t7, $t15

# update value of x

mul $t16, $t5, $t14

# check if x has reached the range

bne $t16, $t0, TaylorLoop

# calculate arcsin of x

mul.s $f0, $t14, $t5

# calculate time-of-flight

li $t17, 2

li $t18, 32.2

mul.s $f1, $f0, $t17

div.s $f2, $f1, $t18

# print time-of-flight

li $v0, 4

la $a0, tflight

syscall

li $v0, 2

mov.s $f12, $f2

syscall

li $v0, 4

la $a0, newline

syscall

# calculate maximum height

li $t17, 2

li $t18, 3600

mul.s $f3, $f0, $t17

li $t19, 2

li $t20, 3

div.s $f4, $f3, $t18

mul.s $f5, $f4, $f4

li $t21, 200

mul.s $f6, $f5, $t21

# print maximum height

li $v0, 4

la $a0, hmax

syscall

li $v0, 2

mov.s $f12, $f6

syscall

li $v0, 4

la $a0, newline

syscall

# calculate angle trajectory

li $t17, 2

li $t18, 3600

mul.s $f7, $f0, $t17

div.s $f8, $f7, $t18

li $t19, 2

mul.s $f9, $f8, $t19

li $t20, 180

div.s $f10, $f9, $t20

# print angle trajectory

li $v0, 4

la $a0, theta

syscall

li $v0, 2

mov.s $f12, $f10

syscall

li $v0, 4

la $a0, newline

syscall

li $v0, 10

syscall

The following in MIPS does not work since more registers like $t10,$t11... are being used which are not in memory. For the program to work, the code needs stacking and also in MARS compiler there are no such functions to load "li $t2, 32.2" since we are loading a float to an integer. Please fix the issue and make sure the code works in MARS. The code needs to output the time of flight in seconds, maximum height in feet and angle trajectory in degrees from taking the range input in yards (the maximum range is 42240 yards).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

2. What type of team would you recommend?

Answered: 1 week ago

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago