How the above code actually accomplishes recursion

Assignment Help Basic Computer Science
Reference no: EM13326819

Consider the recursive implementation of the factorial function

fact: ; recursive function
n equ 8
push rbp
mov rbp, rsp
sub rsp, 16 ;make roomfor storing n cmp rdi, 1 ; compare argumentwith 1
jg greater ; if n <=1, return 1
mov eax, 1 ; set return value to 1
leave
ret
greater:mov [rsp+n] , rdi ; save n
dec rdi ; call factwith n -1
call factmov rdi, [rsp+n] ; restore original n
imul rax, rdi ;multiply fact(n-1) n
leave
ret

1 Explain how the above code actually accomplishes recursion

2 Either using a step by step debugger or by manually executing the instructions as would an appropriate ISA computer (that is, you show each step and intermediate result), go through the rst three recursions of ten factorial and display each of the steps and values of the dierent relevant variables and relevant registers of the machine.

3 How does the recursion end - as a concrete example, what happens for ten factorial as the nal returned value is being computed and why does the recursion stop?

Reference no: EM13326819

Questions Cloud

Advantages of adopting the abc costing system : Calculate the difference between the full unit cost for products X and Y calculated under the traditional costing system and that calculated under the ABC costing system and explain the differences calculated in (c) above for both products.
Obtain the velocity of the car : A car is traveling along a straight road at a velocity of +39.0 m/s when its engine cuts out. For the next ten seconds the car slows down, Find the velocity of the car at the end of the initial ten-second interval
Greta starts an internet-based grocery delivery service : Administrative work: Exactly 2 workers are necessary to perform the administrative work for the business to operate. The administrative workers do not generate revenue.
Find th minimum agle-thaita that the ladder can make : A uniform ladder of length l an weight 100 N rests against a smooth vertical wall. The coefficient of static friction between the bottom of t ladder and the floor is 0.5.
How the above code actually accomplishes recursion : How does the recursion end - as a concrete example, what happens for ten factorial as the nal returned value is being computed and why does the recursion stop?
At what rate do deuterons strike the block : A beam of 16MeV deuterons (m=2mp) from a cyclotron falls on a copper block. The beam is equivalent to a current of 15 microA, At what rate do deuterons strike the block
What is the effect of the use of artificial of pea plants : For the design include the independent variable, the dependent variable, two possible controls, and 2 units of measurement the researcher should use and what the unit should be used to measure.
Are unions good or bad for the economy how do unions : Are unions good or bad for the economy? How do unions at GM and Ford affect employment levels and wages? How do unions affect other industries in terms of employment and wage levels?
What was the release height : A basketball is thrown horizontally with an initial speed of 4.90 m/s. A straight line drawn from the release point to the landing point makes an angle ? = 27.0° with the horizontal. What was the release height

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write bash shell script filestatic to examine number files

Write bash shell script filestatic. Script should examine the number files in directories given as arguments (parameters) to this script.

  Describe retail events in terms of pci compliance standard

You visit retail establishment, shop around, and ultimately carry several products to one of the point of sale. Document each main events just explained and describe them in terms of PCI compliance standard.

  Investigate and discuss how data is structured

Choose any two of the problem areas and discuss in detail how the database approach solves the problem when compared to alternative approaches.

  Using sequential logic, counters and shift registers propose

using sequential logic, counters and shift registers propose a more complex system utilizing some of the more complex sub systems. example a motion acitavated light. Needs to be somthing other then a light example like motors or somthing

  Determining contents of memory of specified address

Find the contents of memory from address 0x1800 up to, but not including, 0x1809, after this code is executed.

  The village of marengo conducted a census

But instead of writing your pseudocode/program for "fewer than 300" households, write your pseudocode/program for EXACTLY 7 households.

  Explain physical condition for alarm in logic truth table

Write truth table in the order of T P F L. Make sure to recognize corect physical condition for alarm in the logic truth table.

  Write a mips program that will alter an array of 100 doubles

Write a MIPS program that will alter an array of 100 doubles. No input or output is required. We will assume somebody else did it. Your program modifies the elements in the array as described

  Identify organizations that may be susceptible to each type

Identify organizations that may be susceptible to each type of attack and explain what the perpetrators might hope to gain by infiltrating their systems.

  You are to design and construct a 3-bit synchronous counter

You are to design and construct a 3-bit synchronous counter with an enable (EN) input. The counter is to count in the prescribed squence shown below if EN is true at the next active clock transition

  Explaining regular language and context-free language

Let L1 be a regular language and L2 be a context-free language, both defined over the same alphabet Σ.

  List all the possible techniques that you might use

Elmwood College Situation: The school is considering a new system that will speed up the registration process. As a systems analyst, you are asked to develop a plan for fact-finding.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd