Unit1 Os Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

UNIT I OVERVIEW OF SYSTEM SOFTWARE

Assemblers & Macro Processors: Simple Assembly Scheme, Pass Structure of


assemblers, Macro Definition and Call, Macro Expansion, Nested Macro Calls,
Linkers and Loaders: Introduction, Relocation and linking Concepts and Types of Loaders.

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.

Example: MASM , TASM

Basic assembler function: (5 basic function)

• Convert mnemonic operation code to their equivalent machine language.

• Convert symbolic operands to their equivalent machine address

• Build machine instruction in the proper format (format 1,2,3,4)

• Convert the data constant to internal machine representation

• Write the object program and assembly listing.

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)

Simplified Instructional Computer (SIC) is a hypothetical computer that has hardware


features that are often found in real machines. There are two versions of this machine:

1.SIC standard Model

2.SIC/XE(extra equipment or expensive)

Object programs for SIC can be properly executed on SIC/XE which is known as
upward compatibility

• SIC architecture contains: Memory, Registers, Data format, Instruction


formats, Addressing modes, Instruction set, Input and output

Below are some examples given below

2
Assembler table and logic:

• OPTAB (Operation table)

• SYMTAB (Symbol table)

• LOCCTR (location counter)

Machine dependent assembler features:

• Machine dependent assembler features are specific to a particular computer


architecture and are used to optimize code for that architecture. These features allow
the programmer to take advantage of the unique capabilities of a particular machine to
produce more efficient code.
• There are 2 main machine dependent assembler features
1. Instruction format and addressing modes
2. Program relocation

3
1. Instruction format and addressing modes:

There are 4 types of instruction formats:

Format 1: it consists of 1 byte and one op code


example: RSUB
Format 2: it consists of 2 bytes, one op code followed by register
Format 3: it consists of 3 bytes
• Opcode-6 bits
• Immediate addressing modes- 1 bit
• Indexed addressing modes- 1 bit
• Base relative addressing modes-1 bit
• Program relative addressing modes-1 bit
• Format- 1 bit
• Displacement- 12 bits
Format 4: it consists of 4 bytes
It is the same as the format 3 but it should contain a symbol

2. Program relocation:

4
Machine independent assembler features:

Assembler designer options:


Assemblers are software tools that translate assembly language code into machine language
code. There are several design options for assemblers

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.

Advantages and disadvantages:

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.

Basic Macro Processor Function:


• Macro Definition
• Macro Expansion
• Macro Invocation(calling)

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.

Macro processor -data structure


1. NAMETAB- Stores macro names
2. DEFTAB-Contains macro definition, macro prototype, macro body statements
3. ARGTAB-When macro innovation statements are recognized the arguments are
stored in argument table

Macro processor -algorithm

1. Processing: processing the procedure

2. Define: called when the macro definition are recognized entries and stored

3. Expand: argument values in the tab and are expanded

4. Get line: gets the next line to be processed

5. Expanding: set to true or false

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:

%let unique_label = %sysfunc(putn(%sysfunc(datetime()), datetime19.));

%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

▪ A linkage editor produces a linked version of the program (load module or


executable image), which is written to a file or library for later execution.

▪ 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.

• Dynamic linking is better than the static LINKING

• 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.

ALGORITHM AND DATA STRUCTURE FOR A LINKING LOADER:

• Pass 1 assigns addresses to all external symbols.


• Pass 2 performs the actual loading, relocation, and linking.
• The main data structure is ESTAB (hashing table).

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:

T1. Leland L.Beck, System Software – An Introduction to System Programming, Pearson


Education, Third Edition, 2011.

REFERENCES:

R1. D.M.Dhamdhere : System Programming, Tata McGraw Hill, Second Revised Edition,
2011.

R2. Andrew S. Tanenbaum, Albert S.WoodHull: Operating Systems, Design and


Implementation, Third Edition, Prentice Hall, 2012.

R3. RemziH.Arpaci-Dusseau,Andrea C.Arpaci-Dusseau,”Operating Systems-Three easy


pieces”2nd Edition.

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

You might also like