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...
-
Carr Company provides human resource consulting services to small- and medium-sized companies. Last year, Carr provided services to 700 clients. Total fixed costs were $159,000 with total variable...
-
Voltage fluctuation is given as the reason for \(80 \%\) of all defaults in nonstabilized equipment in a plant. Use the formula for the binomial distribution to find the probability that voltage...
-
Dungan Corporation is evaluating a proposal to purchase a new drill press to replace a less efficient machine presently in use. The cost of the new equipment at time 0, including delivery and...
-
4. What is the net present value of the following stream of cash flows assuming the opportunity cost rate is 12%? Solve NPV using each cash flow and the NPV function in Excel (use basic PV/FV...
-
Table 1 shows Apple's online orders for the last week. When shoppers place an online order, several "recommended products" (upsells) are shown as at checkout an attempt to upsell See table 2 in cell...
-
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"...
-
For each of the following situations, use the IS-LM-FX model to illustrate the effects of the shock. For each case, state the effect of the shock on the following variables (increase, decrease, no...
-
Describe the type of supervisor you are, how you define success as a team (of staff and, or, volunteers), and how you achieve that success. As someone who was being supervised, what helped to...
-
Explain what gives property in the United States of America value for foreign investors.
-
Mary was in the store close to closing time. She was looking at new washers. The salesman told Mary that he could give her the best deal that wouldn't cost her more than $200.00 right that minute and...
-
Large payments are becoming more frequent in recent years, The whistle blower program - is it helpful when it comes to white-collar crimes? Harmful? Why are why not?
-
Evaluate the impact of the community policing ideology on police community relations building with the community served. In doing so, speak to the challenges to implementing community policing.
-
Reliable Repairs & Service, an electronics repair store, prepared the following unadjusted trial balance at the end of its first year of operations: For preparing the adjusting entries, the following...
-
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
-
1. How does marketing create value, and how do firms become more value driven? 2. Describe a firm's stakeholders and how they are impacted by conscious marketing.
-
Beginning inventory 100 units @ $8.00 = $ 800 Purchase # 1 200 units @ $6.00 = 1,200 Purchase # 2 100 units @ $12.00 = 1,200 Total 400 units $3,200 Ending inventory is 150 units. 1. What is cost of...
-
Sam's Ice Creams, a cottage country favourite in Northern Ontario, has launched a new range of ice creams branded as "Summer Flavours." To capitalize on the cottage and tourism season from May to...
Study smarter with the SolutionInn App