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...
-
Wild - Water Works Water Park provides for a fun day by offering a variety of rides. Wild - Water Works Water Park sells tickets at $ 6 2 per person as a one - day entrance fee. Variable costs per...
-
Pleasant scents improve memory during sleep, continued. (a) Outline a better design than that of Exercise 5.7 for an experiment to compare the two treatments (scent or no scent) that students...
-
The Amberssen Specialty Company is a chain of 12 retail stores that sell a variety of imported gift items, gourmet chocolates, cheeses, and wines in the Toronto area. Amberssen has an IS staff of...
-
[ The information presented here applies to questions 8 , 9 , 1 0 , 1 1 , 1 2 , and 1 3 . ] You are working on cash flow projections for a 3 8 , 0 0 0 square foot office building which is occupied by...
-
E&L Consulting, Ltd., is a U.S. corporation that sells lumber products in New Jersey, New York, and Pennsylvania. Doman Industries, Ltd., is a Canadian corporation that also sells lumber products,...
-
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"...
-
Quickfix is rapidly losing business, and management wants to redesign its computer repair processes and procedures to decrease costs and increase customer service. Currently, a customer needing help...
-
A certain random process \(U(t)\) takes on equally probable values +1 or 0 with changes occurring randomly in time. The probability that \(n\) changes occur in time \(\tau\) is known to be \[...
-
The focal points of the two converging lenses shown in Figure P33.121 are denoted by solid dots for the left lens and open dots for the right lens. Draw a simplified ray diagram to locate the final...
-
Suppose that country A has 9,000 worker hours available for production and that it initially has the technology given by case 3 of Exercise 1. Derive its PPF and determine its exact dimensions. data...
-
The table shows experimental values of the variables x and y. The variables are known to be related by the equation y = a e nx where a and n are constants. a. Draw the graph of ln y against x. b....
-
Construct the Nyquist diagram for a single-degree-of-freedom system with hysteretic damping.
-
Classify each of the following as either an ionic or molecular compound. CH 4 Br 2 CaCl 2 KNO 3 CH 4 O LiF Which is the best statement regarding molecular compounds? a. Molecular compounds always...
-
In Problem 8.43, determine the smallest value of for which the rod will not fall out of the pipe. IA -3 in.-
-
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
-
Famas Llamas has a weighted average cost of capital of 8.8 percent. The companys cost of equity is 12 percent, and its pretax cost of debt is 6.8 percent. The tax rate is 22 percent. What is the...
-
The common stock of a company paid 1.32 in dividens last year. Dividens are expected to gros at an 8 percent annual rate for an indefinite number of years. A) If the company's current market price is...
-
(1 point) Bill makes annual deposits of $1900 to an an IRA earning 5% compounded annually for 14 years. At the end of the 14 years Bil retires. a) What was the value of his IRA at the end of 14...
Study smarter with the SolutionInn App