Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(d) Many compilers don't generate machine code directly after lexing, parsing and semantic analysis. Instead they first generate machine-independent code, which is later, possibly after

image text in transcribed

(d) Many compilers don't generate machine code directly after lexing, parsing and semantic analysis. Instead they first generate machine-independent code, which is later, possibly after optimisation, used to generate code for the target architecture. Explain the characteristics of machine-independent code, and the advantages of using them as an intermediate layer in compilation. [10 marks] (e) Describe a scheme for the translation of function definitions and function calls into low-level code (e.g., RISC-V or stack machine code) based on a stack, as discussed in the lectures and the third task of the coursework. Assume that in the source language function calls are of the form f(e1, en) where el, en are expressions, function definitions are of the form f(x1, ...,xn) = BLOCK where BLOCK itself is an expression, and any expression evaluates to a 32- bit (i.e. 4-byte) integer. We also assume that code generation for other kinds of expressions is readily available, e.g., one can use genExp (BLOCK) and genExp (ei) directly. If you use uncommon instructions, please explain their semantics briefly. If you use activation records in your explanation, describe the layout of your activation records. Note that your answer comprises two parts: code generation for function definitions, and code generation for function calls

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago