Modify the grammar of Figure 15.6 to generate jump code for Boolean expressions, as described in Section
Question:
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:
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: 66% (12 reviews)
ANSWER The modified grammar of Figure 156 to generate jump code for Boolean expressions can be repre...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
-
As described in Section 5.7, virtual memory uses a page table to track the mapping of virtual addresses to physical addresses. This exercise shows how this table must be updated as addresses are...
-
Modify the grammar of Figure 2.25 so that it accepts only programs that contain at least one write statement. Make the same change in the solution to Exercise 2.17. Based on your experience, what do...
-
As described in Section 4.5.2, Linux does not distinguish between processes and threads. Instead, Linux treats both in the same way, allowing a task to be more akin to a process or a thread depending...
-
Investment Portfolio and Risk diversification. Analyze the situations that arise in each of the problems and calculate the value or values ?? required for each of these. Problem 2: List and discuss...
-
A heat engine receives heat from a source at 1100 K at a rate of 400 kJ/s, and it rejects the waste heat to a medium at 320 K. The measured power output of the heat engine is 120 kW, and the...
-
Sanchez & Vukmin, LLP, is a full-service accounting firm located near Chicago, Illinois. Last year, Sanchez provided tax preparation services to 500 clients. Total fixed costs were $265,000 with...
-
Rework the decision problem in Example 7, supposing that only 3 of the 20 hard drives required repairs within the first year. Data From Example 7 EXAMPLE 7 Comparing four detergents using an F test...
-
Zimmer Corporation, a U.S. firm, purchased merchandise from Taisho Company of Japan on November 1, 2011, for 10,000,000 yen, payable on December 1, 2011. The spot rate for yen on November 1 was...
-
You have just been hired as a financial analyst for Lydex Company, a manufacturer of safety helmets. Your boss has asked you to perform a comprehensive analysis of the company's financial statements,...
-
A transfer machine has six stations that function as follows: In addition, transfer time = 0.18 min. Average downtime per occurrence = 8.0 min. A total of 20,000 parts must be processed through the...
-
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...
-
One problem (of many) with the code we generated in Section 15.3 is that it computes at run time the value of expressions that could have been computed at compile time. Modify the grammar of Figure...
-
If Maslows hierarchy of needs theory is correct, how can a manager use it to become more effective?
-
What source(s) of law governs contracts? How does one know " which " source (set of legal rules) applies in a given contractual dispute? If a plaintiff prevails in a breach of contract dispute, what...
-
Calvin contracted with Far Flung Antiquities Ltd., an Ontario company, for furniture. His contract terms were for delivery of the cabinets he was shown in the catalogue - called FF Cabinet 1. He paid...
-
Why do the courts subject restrictive covenants in the employment context to greater scrutiny than those arising in the sale of a business?
-
In order to build the Randolph Student center, Fayetteville State University had to remove the old student center building. To accomplish this, Fayetteville State University hired Seven Men...
-
Provide strategies law enforcement leaders can implement to improve the public's perception of law enforcement. Consider including examples of recent deadly force incidents, to include how it was...
-
Selected account balances before adjustment for Alantic Coast Realty at July 31, 2016, the end of the current year, are as follows: Data needed for year-end adjustments are as follows: a. Unbilled...
-
In a system with light damping (c < cc), the period of vibration is commonly defined as the time interval d = 2/d corresponding to two successive points where the displacement-time curve touches one...
-
What is the number of bits per baud for the following techniques? a. ASK with four different amplitudes b. FSK with eight different frequencies c. PSK with four different phases d. QAM with a...
-
Define digital-to-analog conversion.
-
Calculate the bit rate for the given baud rate and type of modulation. a. 1000 baud, FSK b. 1000 baud, ASK c. 1000 baud, BPSK d. 1000 baud, 16-QAM
-
1) Explain how a Preschool program can help to bring a sense of belonging for the child? 2) It is important for a program to provide physical environments that are age-appropriate and that support...
-
Your company decided to organize a special dinner to appreciate all the employees and it has been proposed that the dinner to be held in the middle of December 2021. You have been appointed as the...
-
Select a two-dimensional image to analyze that is either a work of art (photograph, illustration, or painting) or an advertisement. What is the FTC analysis?Use the FTC palette to break down the...
Study smarter with the SolutionInn App