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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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