POWERED BY
📚 ReferMe: Your Academic Companion
A Student-Centric Platform by Pixen
🔹 About ReferMe
ReferMe, by Pixen, offers curated academic resources to help students study
smarter and succeed faster.
✅ Class Notes
✅ Previous Year Question Papers (PYQs)
✅ Updated Syllabus
✅ Quick Revision Material
🔹 About Pixen
Pixen is a tech company helping students and startups turn ideas into reality.
Alongside ReferMe, we also offer:
✅ Custom Websites
✅ Machine learning
✅ Web Applications
✅ E‑Commerce Stores
✅ Landing Pages
https://referme.tech/ https://www.pixen.live
Powered by
hule Pune Un
ai P ive
ib
tr r
vi
sit
Sa
y
Computer Engineering - Third Year
OPERATING SYSTEM- UNIT II
OVERVIEW OF SPOS
Introduction, Features of a Macro facility: Macro instruction
arguments, Conditional Macro expansion, Macro calls within
Macros, Macro instructions, Defining Macro, Design of two pass
Macro processor, Concept of single pass Macro processor.
Introduction to Compilers: Phases of Compiler with one example,
Comparison of compiler and Interpreter.
More Stuff Inside → Click here
Powered by
More Stuff Inside → Click here
Powered by
Q1. Define Macro. What are the advantages of macro facility? How is it
different from functions?
Definition:
A Macro is a single-line abbreviation or a code template that gets
replaced by a sequence of assembly instructions during the macro
expansion phase in assembly language programming.
Explanation:
A macro is a shortcut for a frequently used block of code.
When used in the program, the macro is expanded (i.e., replaced by its
body).
Macro expansion happens during assembly time (not runtime).
It helps in reducing typing and improving code readability.
Advantages of Macros:
Reusability of code without duplication
No overhead of function calls
Easier program modification and maintenance
Enhances code readability
Useful for small, frequently used instruction sets
More Stuff Inside → Click here
Powered by
Difference Between Macro and Function (Subroutine):
Function /
Feature Macro
Subroutine
Expanded during Executed at
Execution
assembly runtime
No call-return Has call and return
Overhead
overhead overhead
Higher (code is Lower (code is
Memory Usage
copied) reused)
More flexible
Less (textual
Flexibility (control flow,
substitution)
return)
Speed Faster Slightly slower
Small, repetitive Complex, modular
Best Use
code blocks code
More Stuff Inside → Click here
Powered by
Q2. Differentiate Between:
(a) Macro vs Subroutine
Aspect Macro Subroutine
Code is expanded Jump to subroutine
Execution
inline and return
Consumes more More efficient memory
Memory
memory use
Slower (jump and
Speed Faster (no jumping)
return)
Use Case Short, repeated code Larger logical units
(b) Compiler vs Interpreter
Aspect Compiler Interpreter
Converts entire
Working Executes line-by-line
program at once
Output Produces object code No object code
Shows all errors after
Error Handling Stops at first error
compilation
Faster execution after Slower due to line-by-
Speed
compile line run
Example Languages C, C++, Java Python, JavaScript
More Stuff Inside → Click here
Powered by
Q3. Macro Definition, Macro Call, and Macro Expansion
Macro Definition Example:
INCR MACRO &ARG
ADD &ARG, =1
MEND
Macro Call:
INCR AREG
Macro Expansion:
ADD AREG, =1
More Stuff Inside → Click here
Powered by
Conclusion:
Macros improve code modularity, readability, and reduce repetition.
They are expanded at assembly time, making execution faster than
functions.
Widely used in low-level programming, embedded systems, and
repetitive code patterns.
Q4. Explain Argument Passing Mechanism in Macros with Examples
Definition:
In macros, arguments (or parameters) are values or labels passed to the
macro when it's called. They are replaced in the macro body during macro
expansion.
Explanation:
Arguments allow macros to be generalized and reused with different
values.
Parameters in macro definition are written using & symbol (e.g.,
&ARG1).
Actual values are provided during macro call.
Types of Parameters:
1. Positional Parameters – Replaced based on their order.
2. Keyword Parameters – Name-value pairs, more readable.
More Stuff Inside → Click here
Powered by
Example:
Macro Definition:
ADDNUM MACRO &A, &B
LOAD &A
ADD &B
STORE RESULT
MEND
Macro Call:
ADDNUM NUM1, NUM2
Macro Expansion:
LOAD NUM1
ADD NUM2
STORE RESULT
Q5. What are AIF and AGO pseudo-ops in Macros? Explain with
Positional Parameters
AIF (Assembly IF):
Conditional branching inside macros.
Syntax: AIF (condition) label
If condition is true, control jumps to label.
AGO (Assembly GO TO):
Unconditional jump inside macro body.
Syntax: AGO label
More Stuff Inside → Click here
Powered by
Example using AIF and AGO:
CHECK MACRO &A
AIF (&A EQ ZERO) SKIP
LOAD &A
ADD ONE
AGO EXIT
SKIP LOAD ZERO
EXIT MEND
Call:
CHECK VALUE
If &A = ZERO, it skips normal processing.
Otherwise, adds 1 to the argument.
Q6. Describe Single-Pass Macro Processor. Give Example of Macro Calls
within Macros
Definition:
A Single Pass Macro Processor performs macro definition, macro
expansion, and replacement in a single left-to-right scan of the program.
Working:
Macro definitions are stored in tables (MDT, MNT).
As soon as a macro call is detected, it is expanded immediately.
Handles nested macro calls (macro calls within macro definitions).
More Stuff Inside → Click here
Powered by
Tables Used:
MNT (Macro Name Table) – stores macro names and pointer to MDT
MDT (Macro Definition Table) – stores macro body line by line
APTAB (Argument Parameter Table) – maps actual to formal
arguments
Example:
OUTER MACRO &X
LOAD &X
INNER &X
MEND
INNER MACRO &Y
ADD &Y
STORE TEMP
MEND
; Macro Call
OUTER NUM
Expansion:
LOAD NUM
ADD NUM
STORE TEMP
More Stuff Inside → Click here
Powered by
Macro Expansion Flow
Conclusion
Argument passing allows macro reuse with flexibility.
AIF and AGO enable control flow within macro bodies.
Single-pass macro processors improve speed and reduce memory usage.
Nested macro calls are supported using stacked expansion.
More Stuff Inside → Click here
Powered by
Q7. Explain various phases of compiler for expression:
x = I + R * 60
Definition:
A compiler translates a high-level language program into machine code
through multiple systematic phases.
Input Expression:
x = I + R * 60
Phases of Compiler with Outputs:
Phase Description Output Example
Converts source ID(x) = ID(I) + ID(R) *
1. Lexical Analysis
code into tokens NUM(60)
Checks grammar
2. Syntax Analysis and builds parse Tree for x = (I + (R * 60))
tree
Ensures type
3. Semantic Analysis correctness, Validates x, I, R, and 60
declaration, etc.
Generates a form
4. Intermediate Code T1 = R * 60, T2 = I + T1, x =
suitable for
Generation T2
optimization
Improves
performance May reuse constants like
5. Code Optimization
without changing 60
output
More Stuff Inside → Click here
Powered by
Diagram: Compiler Phases
Q8. Write Short Notes On:
(a) Compiler
A compiler is a program that translates high-level code into machine-
level code in one shot.
Performs error checking, optimization, and generates executable code.
Examples: C, C++ compilers (GCC, Clang)
(b) Interpreter
Translates and executes source code line-by-line.
Slower than compiler but useful for debugging.
Examples: Python, JavaScript interpreters
Compiler vs Interpreter:
Feature Compiler Interpreter
Whole program at
Translation Line-by-line
once
Speed Faster execution Slower execution
All errors after
Errors Stops at first error
compilation
More Stuff Inside → Click here
Powered by
Q9. Explain Algorithm of Pass-I of Two-Pass Macro Processor
Purpose:
Pass-I of a macro processor is responsible for processing macro definitions,
storing them in tables for expansion during Pass-II.
Algorithm Steps:
1. Read each line of the source code.
2. If line is MACRO, begin macro definition.
3. Add macro name to Macro Name Table (MNT).
4. Store macro body in Macro Definition Table (MDT) line by line.
5. Store formal parameters in Argument List Array (ALA).
6. Continue storing until MEND is encountered.
7. Ignore macro calls (they're handled in Pass-II).
8. Copy all non-macro lines to intermediate code.
Tables Used:
MNT (Macro Name Table): Stores macro name and pointer to MDT
MDT (Macro Definition Table): Stores body of the macro
ALA (Argument List Array): Maps formal and actual parameters
Example:
MACRO
ADDNUM &A, &B
LOAD &A
ADD &B
STORE RESULT
MEND
More Stuff Inside → Click here
Powered by
MNT:
Index Macro Name MDT Index
1 ADDNUM 1
MDT:
Index Instruction
1 LOAD &A
2 ADD &B
3 STORE RESULT
4 MEND
ALA:
Index Parameter
1 &A
2 &B
Conclusion:
Compiler phases work step-by-step to convert code to machine
language.
Macro Processor Pass-I builds internal tables for macro expansion.
More Stuff Inside → Click here
Powered by
Q10: List and justify the data structures used in processing macro
definitions, calls, and expansion
Definition:
In macro processing, certain data structures are used to store macro-
related information like macro names, definitions, and arguments. These
structures help during macro definition, macro call, and macro expansion.
Main Data Structures Used:
1. Macro Name Table (MNT)
Purpose: Stores the names of macros defined in the program.
Fields: Macro name, index to Macro Definition Table (MDT)
Used During: Macro definition and expansion
Justification: Allows quick lookup of macro names when a macro call is
encountered.
2. Macro Definition Table (MDT)
Purpose: Stores the body (instructions) of each macro.
Fields: Line-by-line macro definition, including MEND
Used During: Macro definition and expansion
Justification: Stores actual macro code to be substituted during
expansion.
3. Argument List Array (ALA)
Purpose: Maintains mapping between formal parameters (in macro
definition) and actual arguments (in macro call).
Fields: Index, Formal parameter (e.g., &A), Actual parameter (e.g.,
NUM1)
Used During: Macro call and expansion
More Stuff Inside → Click here
Powered by
4. Keyword Parameter Default Table (KPDT) (Optional)
Purpose: Stores default values for keyword parameters.
Used During: Macro call
Justification: Helps substitute default values if keyword parameters are
not explicitly provided.
5. Sequence Symbol Table (SST) (For nested macros)
Purpose: Used when macro calls are nested or recursive.
Used During: Expansion
Justification: Tracks unique instance of each macro to avoid name
conflicts.
Diagram: Macro Processing Tables
More Stuff Inside → Click here
Powered by
Example:
MACRO
INCR &ARG
LOAD &ARG
ADD =1
STORE &ARG
MEND
...
INCR NUM1
MNT: Entry for INCR
MDT: LOAD &ARG, ADD =1, STORE &ARG, MEND
ALA: &ARG → NUM1
During expansion, &ARG is replaced with NUM1.
Conclusion:
Macro processing involves storing macro names, definitions, and
parameters.
Each data structure has a specific role in defining, tracking, and
expanding macros.
These tables ensure that macro expansion is accurate, efficient, and
manageable, especially in large programs.
More Stuff Inside → Click here