You are on page 1of 5

PRINCIPLES OF SYSTEM SOFTWARE

NAME - ADITYA ROY KARMAKAR

STUDENT ID - 201001102018

BATCH - BCA1

STREAM - BCA(H)

SEMESTER NO. - 2

ASSIGNMENT NO. -2
1)Explain nested macro call with short example.
ANS:
Nested Macro Call :
MACRO
CAL &P
MOVE , AREGR, &P, ADD, ‘I’ (Set of instruction of macro)
MEND
MACRO X Y Z (Argument X,Y,Z passed through &P1,&P2,&P3)
CAL 1 &P1,P2,P3
CAL &P 1 CAL X
MOVE , AREGR X, ADD X, ‘I’
CAL &P 2 CAL Y
MOVE , AREGR Y, ADD Y, ‘I’
CAL & P3 CAL Z
MOVE , AREGR Z, ADD Z, ‘I’
CAL 1 X,Y,Z
MEND

Example :
A macro may be used in the definition of another macro as illustrated below.

#define A(x) x*x

#define cost(A,y) A*y

Program illustrates this concept. In this program, Area is a function of x, and the cost of
painting the area is defined as a function of area in the macro definition.

#include<stdio.h>
#define Area(x) x*x
#define Costpaint(x,y,z) (z*y + Area (x))
void main()
{
int A = 8, B= 6, C = 4;
clrscr();
printf("The area of square= %d\n", Area(A));
printf("Cost of paint= %d\n", Costpaint(A,B,C));
}

2)Write down the advantages and disadvantages of macro assembler.

ANS: The AdvantageS Of Macro Assembler:


● It ensures that many functions need not be implemented twice.

● Fewer overhead, many functions are combined and don’t need to be

created an intermediate file.

● Flexibility with the features of combinations of macro and assembler.

The Disadvantages Of Macro Assembler:

The result of the combination of macro processing and pass 1

assembler sometimes suffers from core memory problem of it increases

the complexity of program translation.

3) Write down the advantages and disadvantages of compiler and go


loader.

ANS: Advantages of Compiler and go loaders:

- Simple and easier to implement.

- No additional routines are required to load the compiled code

into the memory.

Disadvantages of Compiler and go loaders:

- Wastage in memory space due to the presence of the assembler.

- There is a need to re-assemble the code every time it is to be run.

- It becomes increasingly difficult to handle large number of segments when the input code is
written in a variety of HLL say one routine in pascal and one in FORTRAN and so on.

- Such loaders make designing modular programs and systems near impossible.

4) What is Lex and YACC compiler?

ANS:

LEX
Lex is a computer program that generates lexical analyzers. Mike Lex and Eric Schmidt are
the original developers of Lex. It is a standard lexical analyzer generator on various UNIX
systems. Lex is specified as a part of the POSIX standard. Generally, Lex is used with the
Yacc parser generator. Furthermore, Lex reads an input stream specifying the lexical
analyzer. Then, it outputs the source code implementing the lexer in the C language.

A Lex file consists of the following three sections:

Definition: Defines macros and imports header files written in C.

Rules: It contains regular expression patterns with C statements. When the lexer identifies
that the text in the input matches a given pattern, it will execute the associated C code.

Auxiliary Function: This section consists of C statements and functions.

YACC

Yacc stands for Yet Another Compiler-Compiler. Stephan C. Johnson developed it, and it is
used in UNIX systems. It is a standard utility on BSD and AT&T UNIX. Additionally, GNU
based Linux distributions include Bison, forward-compatible Yacc replacement.

Moreover, the input to Yacc is a grammar of C code that is attached to its rules. The output is
a shift-reduce parser in C. After recognizing the rule, it executes the C code associated with
each rule. Further, the typical actions include generating the parse tree.

5) Write down the features of scanning and parsing in brief.

ANS:

Scanning: Turning source code into a token stream. This stage removes white space and
comments, and identifies what kind of token each piece of the code is.

Parsing: Turning a token stream into a parse tree. This stage checks that the sequence of
tokens is grammatically correct and can be grouped together according to the specifications
of how the language works.

6)Differentiate between macro and subroutine with examples.

ANS:

Macro Subroutine
Macro can be called only in the program it is Subroutine can be called from other
defined. programs also.

Macro can have a maximum of 9 Can have any number of parameters.


parameters.

Macro can be called only after its definition. This is not true for Subroutine.

A macro is defined inside: Subroutine is defined inside:


DEFINE … FORM …..
…. …..
END-OF-DEFINITION. ENDFORM.

Macro is used when the same thing is to be Subroutine is used for modularization.
done in a program a number of times.

7)Explain with an example of a relocation loader.

You might also like