Professional Documents
Culture Documents
Show machine code generated for following assembly level program along with data structures entries
Explain the working of macro processor along with the data structures used in it
Draw and Explain the various phases of compilers with suitable example.
Modify the given grammar and construct a Predictive parser table explaining each step.
E->E+T|T T->T*V|V V-> id.
For a given grammar below, Construct operator precdence relation matrix, assuming *, + are binary
operators and 'id' is terminal symbol, and E as Non terminal.
E->E+E E->E*E E->id Apply operator precedence parsing algorithm for the statement ' id + id * id'
Explain the working of shift reduce parser along with suitable example
What is code optimization? Explain machine dependent code optimisation techniques with suitable
example
Discuss various issues that occur in the code generation phase of the compiler.
Enlist different types of noodles and explain compile and go loader in detail
Explain the working of compiler phases for following expression Position = initial + rate * 60.
Generate three address code for the following logical expression. If a<b then 1 else 0
A one pass assembler generates code and for any undefined symbols, leaves a slot to be filled in, and remembers it in
a table or other data structure. Then where the symbol is defined, it fills in its value at the right place or places, using
the information from the table.
The reason for using a two pass assembler traditionally has been that the target program doesn't fit in memory, leave
alone the source. The gigantic source program is read, line by line, from the punch tape reader, and the table of
labels is kept in internal memory. (I've actually done that, on ISIS, the first development system of Intel, with an
8080.) The second time around the source tape is again read from the beginning, but the value of all labels is known,
and as each line is read, the target program is punched out to tape. On a memory starved 16 bit Intel 8086 system this
was still a useful technique to have a heavily documented source file that can be much larger than 64 Kbyte, with
hard disk or floppy substituted for paper tape.
Nowadays there is no need to do two passes, but this architecture is still in use. It is slightly simpler, at the expense
of I/O.
The basic block is a set of statements. The basic blocks do not have any in and out branches except entry and exit. It
means the flow of control enters at the beginning and will leave at the end without any halt. The set of instructions of
basic block executes in sequence.
Here, the first task is to partition a set of three-address code into the basic block. The new basic block always starts from
the first instruction and keep adding instructions until a jump or a label is met. If no jumps or labels are found, the
control will flow in sequence from one instruction to another.
Input: The input for the basic blocks will be a sequence of three-address code.
Output: The output is a list of basic blocks with each three address statements in exactly one block.
METHOD: First, we will identify the leaders in the intermediate code. There are some rules for finding leaders, which are
given below:
The instructions that target a conditional or unconditional jump statement are termed as a leader.
Any instructions that are just after a conditional or unconditional jump statement will be a leader.
Each leader’s basic block will have all the instructions from the leader itself until the instruction, which is just before the
starting of the next leader.
Flow Graph
It is a directed graph. After partitioning an intermediate code into basic blocks, the flow of control among basic blocks is
represented by a flow graph. An edge can flow from one block X to another block Y in such a case when the Y block’s
first instruction immediately follows the X block’s last instruction. The following ways will describe the edge:
Y immediately follows X in the original order of the three-address code, and X does not end in an unconditional jump.
REF:- https://www.tutorialandexample.com/basic-blocks-and-flow-graphs-compiler-design