You are on page 1of 6

1) difference between application program and system program

ANS)

2) explain macro and macro expansion , list differet feateus of macro with example
ANS)
A macro in the context of System Programming and Compiler Construction (SPCC) is
essentially a single instruction that expands into a set of instructions to perform a particular task.
Macro expansion is the process of replacing the macro instruction with the actual set of
instructions it represents.

Macro Expansion:

When a macro processor encounters a macro instruction in the source code, it replaces it with
the corresponding set of instructions. This process is called macro expansion. Macro expansion
helps to make the code more readable and maintainable by abstracting complex sets of
instructions into single, high-level commands.

Features of Macros:

1. Abstraction: Macros can encapsulate complex code into a single line, making the code
cleaner and more abstract.
2. Code Reusability: Once defined, macros can be reused throughout the code, which
helps avoid repetition.
3. Efficiency: Using macros can make the code more efficient by reducing the number of
lines and thus the size of the code.
4. Parameterization: Macros can accept parameters, making them more flexible and
powerful.
5. Conditional Compilation: Macros can include preprocessor directives for conditional
compilation, allowing the inclusion or exclusion of code based on certain conditions.

3) pass 2 macro processor flowchart


ANS)

1. Start of Pass 2:
○ The macro processor begins its second pass, which is focused on expanding
macro calls.
2. Read the Next Source Card:
○ The processor reads the next line (source card) from the input file that was
prepared during Pass 1.
3. Search in Macro Name Table (MNT):
○ It searches the Macro Name Table (MNT) for a match to determine if the
operation code on the source card is a macro call.
4. Macro Name Found Check:
○ If a macro name is found in the MNT, it proceeds with expansion. If not, the line is
written to the expanded source file as it is, as no macro expansion is needed.
5. Set Up Argument List Array:
○ Once a macro name is identified, the processor sets up an array to hold the
arguments passed in the macro call.
6. Macro Definition Table Pointer (MDTP) Adjustment:
○ The MDTP is set to the index from the MNT entry, pointing to the correct location
in the Macro Definition Table (MDT) to begin macro expansion.
7. Increment MDTP:
○ The MDTP is incremented to get the next line from the MDT.
8. Get Line From MDT:
○ The processor fetches the line from the MDT, which contains the macro template
to be expanded.
9. Substitute Arguments:
○ The arguments from the macro call are substituted into the macro template.
10. Check for MEND:
○ If the line fetched is the 'MEND' pseudo-operation, indicating the end of the
macro definition, the processor will loop back to read the next source card. If it's
not 'MEND', it means there are more lines to be processed for this macro, and
the processor continues to substitute arguments and expand.
11. Write Expanded Source Card:
○ The expanded source lines are written out to the expanded source file.
12. END Pseudo-op Check:
○ If the 'END' pseudo-operation is encountered, this indicates the end of the source
file.
13. Supply Expanded Source File:
○ The fully expanded source file is now ready to be supplied to the assembler for
further processing.

This second pass is critical because it translates macro instructions into the actual code that the
assembler can understand. The MNT and MDT are used to keep track of the macros and their
definitions, and the arguments are substituted into the macro body to create the expanded code.
This process is repeated for each macro call in the source file until all have been expanded.
4) explain different types of statement used in assembly with respect to system programming

ANS)

5) diff between compiler and interpreter

ANS)

Compiler Interpreter

Compilers scan the entire The program is interpreted/translated


program in one go. one line at a time.

As and when scanning is One line of code is scanned, and


performed, all the errors are errors encountered are shown.
shown in the end together, not line
by line.
Compilers convert the source Interpreters do not convert the source
code to object code. code into object code.

The execution time of compiler is It is not preferred due to its slow


less, hence it is preferred. speed. Usually, interpreter is slow, and
hence takes more time to execute the
object code.

Compiler doesn’t require the It requires the source code for


source code for execution later. execution later.

Programming languages that use Programming languages that uses


compilers include C, C++, C#, interpreter include Python, Ruby, Perl,
etc.. MATLAB, etc.

Compiler can check syntactic and Interpreter checks the syntactic errors
semantic errors in the program only.
simultaneously.

Compiler are larger in size. Interpreters are smaller in size.

Compilers are not flexible. Interpreters are relatively flexible.

Compilers are more efficient. Interpreters are less efficient.


6) write short note on assembler , macro processor, loader, linker, compiler, interpreter

ANS)

Assembler: An assembler is a program that translates assembly language, a low-level


language with mnemonics, into machine code that the processor can execute. Each assembly
language instruction corresponds to one machine language opcode. Assemblers may provide
macros and handle symbolic names for memory locations, making the programming process
less error-prone and more readable.

Macro Processor: A macro processor is a software tool that allows for text substitution and
expansion of predefined patterns, known as macros, within source code. Macros are typically
used to abstract code patterns that are used repeatedly throughout the program. The macro
processor expands these patterns into the specific sequences of code they represent before the
program is compiled or assembled.

Loader: A loader is a part of the operating system that loads executable files from storage into
memory to be run on the CPU. It sets up the initial execution context (like stack, heap, and
initialized data) and transfers control to the loaded program. The loader may also perform
relocation and linking of dynamic libraries at runtime if necessary.

Linker: A linker is a utility that combines multiple object files generated by a compiler into a
single executable program. The linker resolves references between the object files, assigns final
memory addresses to functions and variables, and handles external symbols by resolving them
to the correct addresses within other modules or libraries.

Compiler: A compiler is a complex program that translates high-level programming languages


into machine code. It performs several tasks such as lexical analysis, parsing, semantic
analysis, optimization, and code generation. A compiler typically generates object code that
needs to be linked before it can be executed on the target machine.

Interpreter: An interpreter directly executes instructions written in a programming or scripting


language without previously compiling them into machine language. It reads high-level code and
performs the specified operations in real-time. Interpreters are often used for scripting
languages and are useful for rapid application development, but they usually result in slower
execution when compared to compiled programs.

Each component plays a crucial role in the software development process, from writing code in
high-level or assembly languages to executing it on a machine. Assemblers, compilers, and
interpreters handle the translation of code, macro processors provide convenience in code
writing, and loaders and linkers manage the organization and execution of code at the system
level.

You might also like