You are on page 1of 59

2016 PYQ

Section A
Question 1 :-
(a) What is a load-and-go type assembler ?? How is it used
in program development ?
Ans.)

Page no. - 23 -> ch3 at bottom of the page

Load-and-go assembler generates their object code in memory


for immediate execution. Since no object program is written out,
no loader is needed. It is useful in a system with frequent program
development and testing.
(b) Briefly explain the structure of a section table in a.two
pass assembler
Ans.)

Question 2 :-
(a) What are the major tasks of a Linker during
program development ?
Ans.)The major task of a linker is to search and locate referenced module/routines
in a program and to determine the memory location where these codes will be
loaded, making the program instruction to have absolute references.
(b) What is relocation ? Explain different ways by -which
assembler can pass relocation information to the linker.
Ans.)

Page no. 7&8 ->ch-4

Question 3 :-
Write the regular expressions for the following
(a) A number string (non-empty sequence of decimal
digits) that has a value strictly greater than 65. Assume
that leading zeroes are allowed.
ANS->
(b) A set of strings of a's and b's where number of b's
is a multiple of three and there can be any number
of a's.
ANS->
(a*ba*ba*ba*)*
(c ) All strings of letters that contain the five vowels in
Order.

ANS->
Letter ->[b-d f-h j-n p-t v-z]

String -> (Letter|a)* (Letter|e)*(Letter|i)* (Letter|o)* (Letter|u)*

want -> other* a (other|a)* e (other|e)* i (other|i)* o (other|o)* u


(other|u)*

other -> [bcdfghjklmnpqrstvwxyz]

Question 4 :-
(a) What is the purpose of yytext and yyleng variahles
in a LEX program
ANS->
A string named yytext. This string contains a sequence of
characters making up a single input token. The token is read from
the stream yyin, which, by default, is the standard input (stdin).

An integer variable named yyleng. This gives the number of


characters in the yytext string.

(b) Consider the following grammar


E → EORE
E → EANDE
E → NOTE
E → (E)
E → TRUE
E → FALSE
E → ID

Show that this grammar is ambiguous by parsing a string.


ID AND ID OR ID
Question 5 :-
Consider the following augmented grammar (S is non-terminal
and 1 and e are terminal symbols) and the corresponding LR
parsing table :

(0) S' → S
(1) S → iSeS
(2) S → iS
(3) S→a
Parse the input string iiaea using the above parsing table.

Question 6 :-
(a) What is Syntax-Directed Translation ? What is it used
for ? (page304)
A syntax-directed defnition (SDD) is a context-free grammar together
with attributes and rules. Attributes are associated with grammar
symbols and rules are associated with productions. If X is a symbol and
a is one of its attributes, then we write X.a to denote the value of a at a
particular parse-tree node labeled X .

In syntax directed translation, along with the grammar we associate


some informal notations and these notations are called as semantic
rules.

So we can say that

1. Grammar + semantic rule = SDT (syntax directed translation)

● In syntax directed translation, every non-terminal can get one or


more than one attribute or sometimes 0 attribute depending on the
type of the attribute. The value of these attributes is evaluated by
the semantic rules associated with the production rule.

● In the semantic rule, attribute is VAL and an attribute may hold


anything like a string, a number, a memory location and a complex
record

● In Syntax directed translation, whenever a construct encounters in


the programming language then it is translated according to the
semantic rules define in that particular programming language.

The syntax directed translation scheme is used to evaluate the order of


semantic rules

(b) Write three address code for the following assignment


statement
a = b + c* 4 - d

Question 7 :-
(a) What is an activation record ?
an activation record is used to store information about the status of the
machine, such as the value of the program counter and machine
registers, when a procedure call occurs.

OR
An Activation Record is a data structure that is activated/ created when a
procedure/function is invoked, and it includes the following data about the function.

(b) What are the three primary tasks of a code generator ?


A code generator has three primary tasks:
instruction selection,
register allocation and assignment,
instruction ordering.

Section B
Question 8 :-
(a) What are the steps taken by a single pass assembler if
the type of the mnemonic encountered in a parsed line of
an assembly language program specifies a machine
instruction?

(b) Given the following Section-tables for two object files


filel.obj and file2.obj and the corresponding symbol
tables, explain the linking process and show the layout of
the combined section table.
b)
Question 9 :-
(a) Write a Lex- program that counts all strings in the input
with length greater than three.
%{
int len=0, counter=0;
%}

%%
[a-zA-Z]+ { len=strlen(yytext);
if(len > 3)
{counter++;} }
%%

int yywrap (void )


{
return 1;
}

int main()
{
printf("Enter the string:");
yylex();
printf("\n %d", counter);
return 0;
}

(b) Consider the following C code fragment:


if (a < b)
x = 10;
else
y = 10:
List the possible lexemes, tokens and their attribute Values
that would be identified by the lexical analyzer while scanning
the above code fragment.
Ans.)

b)

Question 10 :-
Consider the context-free grammar.
S → aX
X → bX | bY
Y→c
The symbols S,X,Y are non-terminals and S is the start symbol
while a, b and c are terminal symbols.
(i) Give the canonical collection of LR (0) items for this
Grammar.
Ans.)

(ii) Is this Grammar SLR ? Prove by constructing SLR parsing


table.
Ans.)

Question 11 :-
(a) Consider the following syntax-directed definition over
the grammar defined by G where S, A, Sign are
non-terminals. There is a special terminal symbol "n" that
is lexically matched by any string of one numeric digit
and whose value is the numeric value of decimal
representation
Identify the attributes associated with the grammar
symbols and classify them as synthesized and inherited.
Ans.)

(b) Write a Syntax Directed Definition (SDD) for generating


a Three Address Code for the If statement specified by
the following grammar rule:
S → if (B) S1 where S is any statement and B is a
Boolean expression. Assume the appropriate functions
and attributes to be used in SDD.
Question 12 :-
(a) Write type expressions for the following :
(i) An array of pointers to floats, where array index ranges
from 1 to 100.
pointer(Array(1….100 , floats))
(ii) Function whose domain is a record containing an
integer and a character and range is an integer
int function(int a , char b)
int * char ->pointer(integer)

(b) Consider the following context-free grammar


S → Sa
S → bS
S→c
Is the grammar LR(1) ? Justify your answer.
Ans.)

Question 13 :-
(a) Briefly explain the structure of an activation record.
How is variable length array allocated memory in the
stack of activation records ?
Page 433-434
Page 438-439

(b) What is the significance of the cost of an instruction


while code generation ? How is it evaluated ? Explain with
example.
The cost of an instruction to be one plus the costs associated with the
addressing modes of the operands. This cost corresponds to the length
in words of the instruction. Addressing modes involving registers have
zero additional cost, while those involving a memory location or constant
in them have an additional cost of one, because such operands have to
be stored in the words following the instruction.
Some examples:
● The instruction LD R0, R1 copies the contents of register R1
into register R0. This instruction has a cost of one because no
additional memory words are required.
● The instruction LD R0, M loads the contents of memory location
M into register R0. The cost is two since the address of memory
location M is in the word following the instruction.
● The instruction LD R1, *100(R2) loads into register R1 the
value given by contents(contents(100 + contents(R2))). The cost is
two because the constant 100 is stored in the word following the
instruction.

2018 PYQ (10 Dec)

Section A
Question 1 :-
(a) Briefly explain a hybrid compiler with the help of an
example.
Ans.)

(b) How is the pseudo opcode DB different from RESB?

Question 2 :-
(a) What are the main objectives of the linking process?
(b) What-are the advantages and disadvantages of a load-
and-go type assembler?

Ans.)

(c) What is phrase level error recovery in LR parsing


method?
Ans.) not in syllabus

Question 3 :-
(a) Describe the structure of a Lex program.
A Lex program has the following form:
declarations
%%
translation rules
%%
auxiliary functions

The declarations section includes declarations of variables, manifest


constants (identifiers declared to stand for a constant, e.g., the name of
a token), and regular definitions, in the style of Section 3.3.4. The
translation rules each have the form
Pattern { Action }
Each pattern is a regular expression, which may use the regular de-
-finitions of the declaration section. The actions are fragments of code,
typically written in C, although many variants of Lex using other
languages have been created.
The third section holds whatever additional functions are used in the
actions.Alternatively, these functions can be compiled separately and
loaded with the lexical analyzer.

(b) What is the difference between explicit and implicit


type conversion?
Ans.)The implicit type conversion is also called automatic type
conversion as it is automatically done by a compiler. The type
conversion which is done by the programmer himself is called
explicit type conversion

Question 4 :-
(a) Mention two rules that Yacc uses to resolve parsing
action conflicts.
Ans.)Unless otherwise instructed, yacc resolves all parsing action
conflicts using the following two rules: A reduce/reduce conflict is
resolved by choosing the conflicting production listed first in the
Yacc specification. A shift/reduce conflict is resolved in favor of
shift.

(b) Derive the string "aaabbabbba" (right most derivation)


using the following grammar:
S → аВ | bА
A → a | aS | bAA
B → b | bS | aBB

Question 5 :-
(a) Give three address code for the following arithmetic
expression:
a=b+(-c)

(b) Write four string for each of the following regular


expressions:
(i) (a|b)*a(a|b)(a|b)
{aaa,aaaa,babb,abb}
(ii) a*ba*ba*ba*
language which could have only 3 b’s in them.
{bbb,ababab,bbab,bbba}

Question 6 :-
(a) Differentiate between absolute and relocatable machine
language programs.
Pg no 508
(b) What is the use of heap storage allocation strategy?
Data that may outlive the call to the procedure that created it is usually
allocated on a “heap” of reusable storage. The heap is an area of virtual
memory that allows objects or other data elements to obtain storage
when they are created and to return that storage when they are
invalidated.
(c) What does cost of a program mean? List down some
common cost measures for a program.
(d) Differentiate between static and shared libraries.
Section B
Question 7 :-
(a) What is backpatching in a single pass assembler. How
does it solve the problem of forward referencing?

(b) Following are the section-tables and symbol-tables for


two object files, namely, file1.obj and file2.obj. Using pass
I of linking process, populate the combined section table
and public definition table.
Ans.)
F.Y.I : Not sure if Public definition table is correct or not

Question 8 :-
(a) Draw a flow diagram to show different phases of the
front end of a compiler.

(b)
(c) Explain different components of binary image
produced
Ans.)

(d) Identify tokens, patterns and lexemes in the following


code snippet:
if (x>=y)
a=1;
Tokens = 11 { if , ( , x , > , = , y , ) , a , = , 1 , ; }
Ans.)

Question 9 :-
Consider the following context-free grammar:
E' → E
E → EaT | T
T → TF | F
F → Fb | c
(a) Construct the canonical collection of LR(0) items. Note
that the grammar is already augmented, and E' is the new
start symbol.
Ans.)

(b) Using part (a), build the SLR(1) parsing table for this
grammar.
Ans.)

Question 10 :-
(a) Consider the following syntax-directed definition:
PRODUCTION SEMANTIC RULE

Identify terminal and non-terminal symbols. Find out


attributes associated with the grammar symbols and
classify them as synthesized and inherited.
Ans.)

(b) Write a type expression for "array of 3 arrays of 4


arrays of 5 integers each".

array(3,array(4,array(5,integer)))
Int[3][4][5]
(c) Define kernel items and non-kernel items of LR(0)
items.
Ans.)Kernel items, which include the initial item, S'→ . S, and
all items whose dots are not at the left end. Non-kernel items,
which have their dots at the left end.

Question 11 :-
(a) Consider the following context-free grammar
S → aSbS
S→a
S→c
Is the grammar LR(1)? Justify your answer.
Ans.)

(b) Write a regular expression for all Ps and Qs which


contain an odd number of Qs.
Ans.) P*(QP*QP*)*QP*
Question 12 :-
(a) C language code to compute fibonacci numbers
recursively is shown below:
int f(int n)
{ int t,s;
If (n>2) return 1;
s=f(n-1);
t=f(n-2);
return(s+t);
}
Draw the activation tree for the call f(5).

(b) Generate machine instructions for the following


three-address statement assuming all variables are stored
in memory locations
b= a[i]
Clearly write the assumptions, if any.
2018 PYQ (4 Dec)

Section A
Question 1 :-
(a) Differentiate between static and shared libraries.
Done

(b) What is the disadvantage of single pass assembler.


over two pass assembler?

Question 2 :-
Discuss the major data structures and their organization, used
in an assembler.
Question 3 :-
(a) Consider the following grammar:
S→AB
S→ASB
A→a
B→b
Are the foltowing sentences valid according to the-above
grammar? If yes, derive them.
(i) aabb
i) Yes ,
(ii) abba
II) No,

(b) List the various phases of a compiler. Consider the


following statement of a particular language:
temp=(a*b) / 10;
What will be the output of first phase of compilation?
<id,1> <=> <(> <id,2> <*><id,3> <)> </> <10>

Question 4 :-
Write a Lex program that converts all lower case letters to
uppercase in a text File.
%{
#include<stdio.h>
%}

%%
/*** Rules section ***/
[a-z] printf("%c",yytext[0] - ('a' - 'A'));
0 { return 0;}
%%

int main()
{
FILE *fp;
fp = fopen("test.txt", "r");
if (fp == NULL) { printf("File not found"); }
yyin = fp;

yylex();
return 0;
}

Question 5 :-
Describe the languages denoted by the following regular
expressions!*hey
(i) (a|b)*a(a|b)(a|b)
All strings of a’s and b’s, with an a in the 3rd letter from the right.
(ii) a*b*c*d*........z*
All strings of lowercase letters in which the letters in are in ascending
lexicographic order.
(iii) b*(ab*ab*)*
All strings of a’s and b’s with an even number of a’s.
(iv) a*b*a*b*a*b?a*
All strings of a’s and b’s that contain just two or three b`s
(v) (a|b)*b(a|b)*b(a|b)*
All strings of a’s and b’s that contain at least two b's.

Question 6 :-
(a) What are the advantages of LALR over Canonical LR
parsers?
Ans.) an LALR parser is quite efficient at finding the single correct
bottom-up parse in a single left-to-right scan over the input stream,
because it does not need to use backtracking.
(b) Differentiate between synthesized àttributes and
inherited attributes with the help of'an example.
Ans.) Synthesized attribute is an attribute whose parse tree node
value is determined by the attribute value at child nodes.To illustrate,
assume the following production S → ABC if S is taking values from its
child nodes (A, B, C), then it is said to be a synthesized attribute, as the
values of ABC are synthesized to S.

On other hand an attribute is said to be Inherited attribute if its parse tree


node value is determined by the attribute value at parent and/or siblings
node. In case of S → ABC if A can get values from S, B and C. B can
take values from S, A, and C. Likewise, C can take values from S, A,
and B then S is said to be Inherited Attribute.

Question 7 :-
(a) Translate the following arithmetic expression into:
a[i]=b*c-b*d
(i) Quadruples
(ii) Triples

(b) What is an activation tree?


We can represent the activations of procedures during the running
of an entire program by a tree, called an activation tree. Each node
corresponds to one activation, and the root is the activation of the “main”
procedure that initiates execution of the program. At a node for an
activation of procedure p, the children correspond to activations of the
procedures called by this activation of p. We show these activations in
the order that they are called, from left to right.

Section B
Question 8 :-
(a) What is Position Independent Code? What are its
advantages over ordinary executables?
Ans.)

(b) What is the advantage of dynamic linking over static


linking?
Ans.)Multiple processes that load the same DLL at the same base
address share a single copy of the DLL in physical memory. Doing this
saves system memory and reduces swapping.

(c) Consider the following section tables and symbol


tables? for two files a.obj and b.obj, create the
appropriate data structures formed after Pass 1 of linking
process.
Ans.)
Question 9 :-
(a) Draw the transition diagram for signed floating point
numbers.
(b) Write the regular definitions for comments consisting
of string surrounded" by /* and */ without an intervening */
Character → [a-zA-Z0-9]
Comment → /* (Character|“*/”|(*|/) Character)* */
(c) What do you understand by lexical errors? Give an
example.
A Lexical error occurs when a sequence of characters that does not
match the pattern of any token. Lexical phase error is found during the
execution of the program.
For example :-
Void main() {

int x=10, y=20;

char * a;

a= &x;

x= 1xab; }

In this code, 1xab is neither a number nor an identifier. So this code will
show the lexical error.

Question 10 :-
Consider the following grammer
S→aX
X → bX | bY
Y→c
The symbols S, X, Y are non-terminals and S is the start
symbol while a, b and c are terminal symbols.
(a) Give the canonical LR(0) set of items for the above
grammar.
(b) Compute the FOLLOW sets for all non-terminals. and
give the SLR parsing table (action and goto) for this
grammar.
Ans.)
Question 11 :-
(a) Consider the following grammar:
S→SS+
S → S S*
S→a
Indicate the handle in each of the right sentential forms
and give the bottom up parse for 3rd.
(i) SSS+a*+
(ii) SS+a*a+
(ili) aaa*a++
Possible handles for G are SS+, SS* or `a`. Each sentential form has
multiple handles. Note that the handle must be followed by terminals.
If you still have a choice, always pick the leftmost handle. Why?
Because
in a bottom-up parse (rightmost derivation), the leftmost nonterminals
are reduced first. Thus
a) S[SS+]a*+ // the leftmost handle is SS+
b) [SS+]a*a+ // the leftmost handle is SS+
c) [a]aa*a++ // the leftmost handle is the leftmost `a`

(b) Consider the following grammar where T, B and C are


non-terminals and int, float, num are terminals:
T → BC
B → int
B → float
C → [num]C1
C→E
Given an SDD such that a non-terminal T generates either
a basic type or an array type and the non-terminal B
generates one of the basic types.

Question 12 :-
(a) Briefly explain the structure of an activation record.
Differentiate between the two different types of links (that
connect to other activation records) present in the
activation record with the help of an example.
(b) Generate code for the following three-address
statements (in sequence) assuming a is an array whose
elements are 4-byte values:
x=a[i]
i)for x=a[i]
LD R1, i // R1 = i
MUL R1, R1 , 4 // R1 = R1 *4
LD R2 , a(R1) // R2 = contents(a + contents(R1))
ST x, R2 // x = R2
z=x*y
ii) LD R1, x
LD R2, y
MUL R1, R1, R2 // R1 = R1 * R2
ST z, R1

Question 13 :-
Consider the following augmented grammar:
S' → S
S → id
S → V=E
V → id
(a) Construct the LR (1) parsing table:
(b) Parse the input string id=id using the constructed
parse table.
Ans.) given grammar is wrong.
2019 PYQ

Section A
Question 1 :-
(a) Explain forward reference in assembler with the help of
an example.
Ans.) Page no. -19 - ch3 assembler.
(b) Draw the activation tree for the function calls:
main (){pl();}
pI( ){p2( ); p3( );}
p2(){}
р3(){}

(c) Define inherited attribute with the help of a suitable


example.
Ans.) On other hand an attribute is said to be Inherited attribute if its
parse tree node value is determined by the attribute value at parent
and/or siblings node. In case of S → ABC if A can get values from S, B
and C. B can take values from S, A, and C. Likewise, C can take values
from S, A, and B then S is said to be Inherited Attribute.
(d) Define type synthesis and type inference in the context
of type checking.
Ans.)Type synthesis builds up the type of an expression from the
types of its subexpressions. It requires names to be declared before
they are used. The type of E1 + E2 is defined in terms of the types
of E1 and E2. A typical rule for type synthesis has the form:

if f has type s ! t and x has type s,


then expression f (x) has type t

Type inference determines the type of a language construct from


the way it is used. Looking ahead to the examples in Section 6.5.4,
let null be a function that tests whether a list is empty. Then, from
the usage nul l(x), we can tell that x must be a list. The type of the
elements of x is not known; all we know is that x must be a list of
elements of some type that is presently unknown.
A typical rule for type inference has the form :

(e) Write the structure of a Yacc Program.

(f) Translate the expression a = (-c) * b + (-c) to quadruples.

op arg1 arg2 result


0 minus c t1
1 * t1 b t2
2 + t2 t1 t3
3 = t3 a

(g) Draw the structure of Machine Opcode Table (MOT).


Pseudo Opcode Table (POT) and Symbol Table (SYMTAB)
used in the assembler.
Ans.)
(h) Find the FOLLOW() for every non-terminal in the
following grammar:
S → Bb I Cd
B → aB | E
C → cC | E

(i) What is the difference between a shared library and a


static library?

(j) What are the functions performed by lexical analyser?


Ans.)The lexical analyzer is responsible for removing the white
spaces and comments from the source program. It corresponds to
the error messages with the source program. It helps to identify the
tokens. The input characters are read by the lexical analyzer from the
source code.
(k) How is the symbol table used by lexical and syntax
analyzers of the compiler?
Ans.) When the lexical analyzer discovers a lexeme constituting
an identifier, it needs to enter that lexeme into the symbol table.
(l) Write token name, lexeme and attribute value for the
following statement:
int * a;
Ans.)

(m) Generate the assembly code for the following


sequence of statements. Assume x, y and z are in
memory:
If x < y goto L1
z=0
goto L2
L1 : z = 1
L2 : z = 2

ANS)
LD R1, x
LD R2, y
SUB R1, R1, R2
BLTZ R1, L1
LD R1, #1
ST z, R1
BR L2
L1: LD R1, #1
ST z, R1
L2: LD R1, #2
ST z, R1
Section B
Question 2 :-
(a) Consider the following scetion tables for two objeet
files k.obj and y.obj. After Pass 1 of linking process, show
the content of appropriate data structures formed and
also show the layout of the final exccutable module.

(b) How does Yacc resolve ambiguity in the following


expression grammar?
E → E+E | E*E | id

Page no 293

Question 3 :-
(a) What is Position Independent Code?
(b) Consider the augmented expression grammar
E→E
E→E+T|T
T→T*F|F
F → id
Construct the LR(0) automaton and parse the input string id *id
using shift/reduce parser.
Question 4 :-
(a) Write a type expression for an "array of 4 arrays of 3
integers each".
int [4][3]
array(4,array(3,integer))
array
/ \
4 array
/ \
3 integer

(b) What are the benefits of using quadruple over the triple
in three address code generator?
Ans.)A benefit of quadruples over triples can be seen in an
optimizing compiler,where instructions are often moved around.
With quadruples, if we move an instruction that computes a
temporary t, then the instructions that use t require no change. With
triples, the result of an operation is referred to by its position, so
moving an instruction may require us to change all references to
that result.

(c) Consider the following augmented grammar:


S’ → S
Construct the SLR (1) parsing table.

Question 5 :-
(a) Consider the grammar:
S → BC | DA
C → AA
B→b
A→a
D → ba
Construct LALR parsing table for the above grammar.
(b) What are the limitations of Load-and-Go Assembler?
Question 6 :-
(a) Consider the Syntax Directed Definitions :
T → T1 * F { T.val = T1. val × F. val }
E → T { E. val = T. val }
E → E1 + T { E. val = E1. val + T. val }
T → F { T. val = F. val }
F → G ↑ F { F. val = POWER(F. val, G. val) }
F → G { F. val = G val }
G → digit { G. val = digit.lexval }
Construct annotated parse tree for 1 * 3 ↑ 2 + 5 * 3 and give the
output.

(b) Define handle pruning with the help of a suitable


example.
Removing the children of the left-hand side non-terminal from the parse
tree is called Handle Pruning.

A rightmost derivation in reverse can be obtained by handle pruning.

Example :
(c) Compare and contrast single-pass and two-pass
assemblers.
Ans.)Difference between One Pass and Two Pass
Assemblers:-
The difference between one pass and two pass assemblers are:-

A one pass assembler passes over the source file exactly once, in the same pass
collecting the labels, resolving future references and doing the actual assembly. The
difficult part is to resolve future label references (the problem of forward referencing)
and assemble code in one pass. The one pass assembler prepares an intermediate
file, which is used as input by the two pass assembler.

A two pass assembler does two passes over the source file (the second pass can be
over an intermediate file generated in the first pass of the assembler). In the first
pass all it does is looks for label definitions and introduces them in the symbol table
(a dynamic table which includes the label name and address for each label in the
source program). In the second pass, after the symbol table is complete, it does the
actual assembly by translating the operations into machine codes and so on.

Question 7 :-
(a) What is the output of the following code?
int f(int x, int * y, int ** z)
{
**z+=1;
*y+=2;
x+=3;
return x + *y + **z;
}
int main( )
{
int x, c, *b, **a;
c = 4, b = &c, a = &b;
x=f(c, b, a);
printf("%d", x);
return 0;
}
Output : 21
(b) "Values communicated between caller and callee are
placed in the beginning of callee's activation record."
Why?
Values communicated b etween caller and callee are generally
placed at the beginning of the callee's activation record, so they are
as close as possible to the caller's activation record. The motivation
is that the caller can compute the values of the actual parameters of
the call and place them on top of its own activation record, without
having to create the entire activation record of the callee, or even to
know the layout of that record. Moreover, it allows for the use of pro
cedures that do not always take the same numb er or typ e of
arguments, such as C's printf function. The callee knows where
to place the return value, relative to its own activation record, while
however many arguments are present will appear sequentially b
elow that place on the stack.
(c) Determine the cost of each instruction in the following
assembly code. Assume that each memory access
(including the machine instruction) has cost 1.
LD RO, i
MUL RO, R0,8
LD R1, a(R0)
ST b, R1
Cost : 2 + 2 + 2 + 2 = 8

You might also like