Our GCD program did not employ subroutines. Extend the grammar of Figure 15.6 to handle procedures without
Question:
Our GCD program did not employ subroutines. Extend the grammar of Figure 15.6 to handle procedures without parameters (feel free to adopt any reasonable conventions on the structure of the syntax tree). Be sure to generate appropriate prologue and epilogue code for each subroutine, and to save and restore any needed temporary registers.
Figure 15.6:
Transcribed Image Text:
reg_names : array [0..k-1] of register.name := ["r1, "r2" .., "rk"] -- ordered set of temporaries program + stmt stmt.next.free_reg := 0 program.code := ["main:"] + stmt.code + ["goto exit"] while : stmt expr stmtz stmtz expr.next.free_reg := stmt2.next.free_reg := stmt3.next.free.reg := stmtj.next.free_reg L1:= new.label(); L2 := newJabel() stmtj.code := ["goto" L1] + [L2 ":"] + stmt2.code + [L1 ":"] + expr.code + ["if" expr.reg "goto" L2] + stmt3.code if : stmti expr stmt2 stmtz stmtą expr.next_free_reg := stmt2.next.free reg := stmt3.next.free_reg := stmt4.next.free_reg := stmtj.next.free-reg L1:= new.label); L2 := newJabel() stmtj.code := expr.code + ["if" expr.reg "goto" L1] + stmt3.code + ["goto" L2] + [L1 ":"] + stmt2.code + [L2 ":"] + stmtą.code assign : stmt - id expr stmtz expr.next.free_reg := stmt2.next.freereg := stmtj.next.free.reg stmtı.code := expr.code + [id.stp→name ":=" expr.reg] + stmt2.code read : stmt + id, idz stmt2 stmtj.code := ["a1 := &" id.stp→name] + ["call" if id2.stp>type = int then "readint" else ...] + [idz.stp→name ":= rv"] + stmt2.code %3D -- file write : stmt → id expr stmt2 expr.next_free_reg := stmt2.next.freereg := stmtj.next.free.reg stmtj.code := ["a1 := &" id.stp→name] + ["a2 :=" expr.reg] + ["call" if id.stp type = int then "writeint" else ..] + stmt2.code -- file -- value writeln : stmti + id stmtz stmtj.code := ["a1 := &" id.stpname] + ["call writeln"] + stmt2.code null : stmt €
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 60% (10 reviews)
regnames array 0k1 of registername r1 r2 rk ordered set of temporaries program stmt stmtnextfreereg ...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
The grammar of Figure 15.6 assumes that all variables are global. In the presence of subroutines, we should need to generate different code (with fp-relative displacement mode addressing) to access...
-
Extend the grammar of Figure 2.25 to include if statements and while loops, along the lines suggested by the following examples: abs := n if n < 0 then abs := 0 - abs fi sum := 0 read count while...
-
Repeat Example 2.36 using the grammar of Figure 2.15. Figure 2.15: id(A) id_list_prefix id(C) id_list_prefix id_list_prefix id(B) id(A) id(A) id_list_prefix id_list_prefix id(A) id_list_prefix id(C)...
-
Explain in detail the role of data analytics in healthcare.
-
Reconsider Prob. 8-18. Using EES (or other) software, study the effect of reducing the temperature at which the waste heat is rejected on the reversible power, the rate of irreversibility, and the...
-
Paulson's Pet Store completed the work sheet on page 600 for the year ended December 31, 20--. Owner's equity as of January 1, 20--, was $21,900. The current portion of Mortgage Payable is $500....
-
What are the advantages of using a safe deposit box to store your personal financial documents?
-
The Molokai Nut Company (MNC) makes four different products from macadamia nuts grown in the Hawaiian Islands: chocolate-coated whole nuts (Whole), chocolate-coated nut clusters (Cluster),...
-
The following information is for questions 2 through 9. Paper Company acquired 80 percent of Scissor Company's outstanding common stock for $296,000 on January 1, 20X8, when the book value of...
-
The following accounts appeared in recent financial statements of Continental Airlines: Accounts Payable Flight Equipment Air Traffic Liability Landing Fees Aircraft Fuel Expense Passenger Revenue...
-
Compare and contrast GIMPLE with the notation we have been using for syntax tree attribute grammars.
-
Modify the grammar of Figure 15.6 to generate jump code for Boolean expressions, as described in Section 6.4.1. You should assume short circuit evaluation. Figure 15.6 : type = int then "readint"...
-
A four-year review at the Provincial Hospital in Alotau, Papua New Guinea (Barss 1984), found that about 1/40 of their hospital admissions were injuries due to falling coconuts. If coconuts weigh on...
-
Using BLS data, make a table comparing the changes in employment, unemployment rate, and the level of average hourly wage since the onset of the Great Recession in 2008. Discuss three specific ways...
-
In the figure, a small block of mass m = 0.013 kg can slide along the frictionless loop-the-loop, with loop radius R = 19 cm. The block is released from rest at point P, at height h = 5R above the...
-
The term market access refers to: check all that apply a marketing goal which follows market share whether a retail store is easy to find a prerequisite for a brand to obtain market share the goal...
-
Read the following article, A Day in the Life of a PreK Teacher . Share your thoughts about how this way of life each day will suit you well in your strengths as a teacher and where you anticipate...
-
7. If we assume labor is the only input to production that can be varied, the relationship between the number of barrels of beer Q (in millions) produced at the Boston Beer Company and the number of...
-
How does consensus differ from unanimity in group decision making?
-
After graduating from college and working a few years at a small technology firm. Preet scored a high-level job in the logistics department at Amex Corporation. Amex sells high-quality electronic...
-
Draw the constellation diagram for the following cases. Find the peak amplitude value for each case and define the type of modulation (ASK, FSK, PSK, or QAM).The numbers in parentheses define the...
-
Draw the constellation diagram for the following: a. ASK, with peak amplitude values of 1 and 3 b. BPSK, with a peak amplitude value of 2 c. QPSK, with a peak amplitude value of 3 d. 8-QAM with two...
-
Which characteristics of an analog signal are changed to represent the digital signal in each of the following digital-to-analog conversions? a. ASK b. FSK c. PSK d. QAM
-
The BEAT (Base Erosion and Anti-Abuse Tax), is an alternative minimum tax on US taxpayers that make payments to foreign related parties. It works like this: the base erosion minimum tax is the excess...
-
Durable goods orders, new-home sales, and imports pick up The BEA announced that demand for durable goods rose 3.4% while new-home sales rose 13.4% in the second quarter of 2013. U.S. exports...
-
Chapter 5 2. Consider a simple UDP-based protocol for requesting files (based somewhat loosely on the Trivial File Transport Protocol, or TFTP). The client sends an initial file request, and the...
Study smarter with the SolutionInn App