Professional Documents
Culture Documents
Unit1 Os Notes
Unit1 Os Notes
Unit1 Os Notes
1. ASSEMBLERS
Definition:
The Assembler is a Software that converts an assembly language code to machine code. It
takes basic Computer commands and converts them into Binary Code that Computer's
Processor can use to perform its Basic Operations. These instructions are assembler language
or assembly language.
Assembler Directives:
Assembler directives are directions to the assembler to take some action or change a setting.
Assembler directives do not represent instructions, and are not translated into machine code.
It generates instructions by evaluating the mnemonics (symbols) in operation field and find
the value of symbol and literals to produce machine code.
1
Shifa Fathima I - 27/04/2023
Simple sic assembler:
(simplified instructional computer)
Object programs for SIC can be properly executed on SIC/XE which is known as
upward compatibility
2
Assembler table and logic:
3
1. Instruction format and addressing modes:
2. Program relocation:
4
Machine independent assembler features:
One-pass assemblers read the source code only once and generate machine code in a single
pass, while multi-pass assemblers make multiple passes over the source code to resolve
forward references.
Let us see in detail one by one
5
6
7
Multi pass Assemblers:
• A multi-pass assembler is a type of assembler that processes the source code of a
program through several passes or iterations to generate the final machine code or
object code.
• In a single-pass assembler, the source code is read only once and translated into
machine code in one pass. However, in a multi-pass assembler, the source code is
read multiple times, with each pass generating intermediate code that is used as input
to the subsequent passes.
• The main advantage of using a multi-pass assembler is that it can handle more
complex source code structures and resolve more complex dependencies between
program modules.
8
Summary of assemblers: (just for understanding and not from exam POV)
2.MACRO PROCESSORS
Definition:
Macro instruction is a notational convenience for the programmer. For every occurrence of
macro, the whole macro body or macroblock of statements gets expanded in the main
source code. Thus Macro instructions make writing code more convenient.
Macro processors are generally Machine independent in nature.
9
Macro Processors Algorithm and Data structures:
There are two main types of macro processors: one-pass and two-pass macro processors.
A one-pass macro processor reads through the source code once and expands all macros as it
goes, replacing each macro with its corresponding expansion. This approach is simpler and
more efficient, but it requires all macros to be defined before they are used in the source
code. This means that if a macro is used before it is defined, the one-pass macro processor
will not be able to expand it.
A two-pass macro processor, on the other hand, reads through the source code twice. In the
first pass, it identifies all the macros and their corresponding definitions. In the second pass, it
expands all the macros, now that it has all the necessary information. This approach is more
flexible, as macros can be defined and used in any order, but it is slower and requires more
memory than a one-pass macro processor.
10
In general, one-pass macro processors are suitable for simple programs with few macros,
while two-pass macro processors are more appropriate for larger programs with many macros
and more complex macro definitions.
2. Define: called when the macro definition are recognized entries and stored
11
Generation of unique labels:
• In macro processors, generating a unique label can be achieved using the built-in
functionality of the macro processor itself. Depending on the specific macro processor
you are using, there may be different ways to generate unique labels.
One approach is to use the current date and time to generate a unique label. For example, in
the SAS macro language, you can use the %sysfunc function to get the current date and time
in a specific format, and then use that as the basis for a unique label. Here's an example:
%put &unique_label;
Keyword parameters:
12
3.Linkers and Loaders
Linkers:
➢ Plays a vital role in the execution of the program in the system
➢ Linking and loader are co-related then program will work efficiently
➢ Establishes link btw all modules of the program
1. Compiling different modules of the program
2. Once compiles it generates a executable file and sends to the loading part
▪ When the user is ready to run the linked program, a simple relocating loader
can be used to load the program into memory.
13
There are 2 types of linking
• Static linking
• Dynamic linking
Static linking
❖ Loading the entire program before the execution of the program
Use of memory
Inefficient utilization of memory because everything must be loaded in main
memory whether the particular module or particular functionality is required or not at
the particular time. It covers extra space
Program execution
14
Will be faster because everything will be loaded in the main memory at the starting
it self so when the program execution starts u do need load everything from secondary
memory.
Execution Time
Constant load time for linking because it runs at the start
Changes
After loaded a program into the main memory. Then the changes to be made are
difficult. Once again we have to relink, re-compile and again load.
Dynamic Linking
❖ Loading the program module, module by module one by one we do not need have
the entire program in the main memory before the execution.
Use of memory
Efficient utilization only those memories are in the main memory required for
execution at Particular time.
Program execution
Slower because some memories need to pick up from the secondary memory to the
main memory and then it will be executed. Comes to main memory on demand.
Execution Time
It performs at the run time by the operating system because everything not linked
at the start.
Load time might be reduced in the shared library code if already present in the
memory.
Changes
Required modules are loaded in the main memory which are required at the
particular time by the processors for processing. Particular module can be replaced
easily.
• But fixed program if we know what needs to do be done and do not need
any changes STATIC IS GOOD BECAUSE IT WILL LOAD EVERYTHING
FIRST AND THEN EXECUTES VERY QUICKLY
Summary (just for your reference and not from exam POV)
15
Loaders:
Assemblers and compilers are used to convert source code to object code . the loader
will accept the object code make it ready foe execution and helps to execute .
Loader performs its task via four functions, these are as follows:
1. Allocation: It allocates memory for the program in the main memory.
2. Linking: It combines two or more separate object programs or modules and
supplies necessary information.
3. Relocation: It modifies the object program so that it can be loaded at an address
different from the location.
4. Loading: It brings the object program into the main memory for execution.
Absolute Loader:
The absolute loader transfers the text of the program into memory at the address provided
by the assembler after reading the object program line by line. There are two types of
information that the object program must communicate from the assembler to the loader.
It must convey the machine instructions that the assembler has created along with the
memory address.
It must convey the start of the execution. At this point, the software will begin to run after it
has loaded.
16
17
Conclusion:
Linker and Loader are both important components in the software development process.
The Linker is used during the compilation process to link object files into a single
executable file, while the Loader is used at runtime to load the executable file into memory
and prepare it for execution. Understanding the differences between the two is important
for efficient and effective software development.
18
TEXT BOOK:
REFERENCES:
R1. D.M.Dhamdhere : System Programming, Tata McGraw Hill, Second Revised Edition,
2011.
WEB MATERIALS:
W1.http://codex.cs.yale.edu/avi/os-book/OS8/os8c/slide-dir/
W2.http://as.wiley.com/WileyCDA/WileyTitle/productCd-EHEP002013.html
W3.http://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/
19