Question

In: Computer Science

Reg # 14 X 9 A1 240 B1 380 C1 300 D1 150 E1 105 A2...

Reg #

14

X

9

A1

240

B1

380

C1

300

D1

150

E1

105

A2

340

B2

260

C2

400

D2

190

E2

195

1

Write a MIPS Assembly program function to calculate the factorial of an input number. Analyze the program for the number X (calculated above) and compute the Execution time in a pipelined MIPS at 2.4GHz.

MIPS Assembly

Solutions

Expert Solution

.data
printmsg: .asciiz " \nEnter a number to find factorial : "
printmsg2: .asciiz "Factorial of the number is : "
.text
.globl main
main:
doAgain :
la $a0,printmsg # Load the address of prompt
li $v0,4 # The string print service is specified
syscall # System call is made


li $v0,5 # The integer print service is specified
syscall # System call is made

#move data to s0
move $s0,$v0

#if s0 less than or equal to zero exit
blez $s0,exit
#load 1 to s1 store the factorial
li $s1,1

loop:
mul $s1,$s1,$s0
sub $s0,$s0,1
bnez $s0,loop
la $a0,printmsg2 # Load the address of prompt
li $v0,4 # The string print service is specified
syscall # System call is made

#print result
move $a0,$s1
li $v0,1 # The string print service is specified
syscall # System call is made

j doAgain

exit:

************************************************************************************************************************************

In case of any doubt do ask in the comment section.Hope you like it


Related Solutions

Let f: X→Y be a map with A1, A2⊂X and B1,B2⊂Y (A) Prove f(A1∪A2)=f(A1)∪f(A2). (B) Prove...
Let f: X→Y be a map with A1, A2⊂X and B1,B2⊂Y (A) Prove f(A1∪A2)=f(A1)∪f(A2). (B) Prove f(A1∩A2)⊂f(A1)∩f(A2). Give an example in which equality fails. (C) Prove f−1(B1∪B2)=f−1(B1)∪f−1(B2), where f−1(B)={x∈X: f(x)∈B}. (D) Prove f−1(B1∩B2)=f−1(B1)∩f−1(B2). (E) Prove f−1(Y∖B1)=X∖f−1(B1). (Abstract Algebra)
1. Let (A, B, C, D) and (A1, B1, C1, D1) be two non-degenerate quadrilateral. Explain...
1. Let (A, B, C, D) and (A1, B1, C1, D1) be two non-degenerate quadrilateral. Explain why there is exactly one projective transformation that maps one to the other. 5. Classify the conic x 2−4xy+4y 2−6x−8y+5 = 0. Determine its center/vertex, its axis and its eccentricity.
Show that the curve C(t) = <a1, a2, a3>t2 + <b1, b2, b3>t + <c1, c2,...
Show that the curve C(t) = <a1, a2, a3>t2 + <b1, b2, b3>t + <c1, c2, c3> lies in a plane and find the equation for such a plane.
Translate the phrases to a system of linear equations: y= a1*x+b1 and y=a2*x+b2 with a variables,...
Translate the phrases to a system of linear equations: y= a1*x+b1 and y=a2*x+b2 with a variables, e.g. x and y. What do the y-intercepts represent in your example? What does the solution (or intersection) represent in your example? Solve the system of equation for x and y.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT