SlideShare a Scribd company logo
System Software
Electives
Module 1
•System software: General concept, Assemblers,
loaders, linkers, macros, compilers, interpreters,
operating system, Design of assemblers
• System software is a program designed to run a computer's hardware
and applications and manage its resources, such as its memory,
processors, and devices.
What is System Software?
• System software is software that provides a platform for other
software.
• Some examples can be operating systems, antivirus software, disk
formatting software, computer language translators, etc.
• These are commonly prepared by computer manufacturers.
• This software consists of programs written in low-level languages,
used to interact with the hardware at a very basic level.
• It acts as an intermediary between the user and the computer
hardware, allowing the user to interact with the hardware and use
various applications and programs.
Why use System Software?
• Hardware Communication
• Resource Management
• Security
• User Interface
• Application Support
• Customization
Operating systems are the most important type of system software, as
they provide the foundational framework for all other software and
applications to run on the computer.
Features of System Software
• Memory Management: The OS keeps track of the primary memory and
allocates the memory when a process requests it.
• Processor Management: Allocates the main memory (RAM) to a process and
de-allocates it when it is no longer required.
• File Management: Allocates and de-allocates the resources and decides who
gets the resources.
• Security: Prevents unauthorized access to programs and data using
passwords.
• Error-detecting Aids: Production of dumps, traces, error messages, and other
debugging and error-detecting methods.
• Scheduling: The OS schedules the process through its scheduling algorithms.
Types of System Software
System software module 1 presentation file
System Software Application Software
System Software maintains the system resources
and gives the path for application software to run.
Application software is built for specific tasks.
Low-level languages are used to write the system
software.
While high-level languages are used to write the
application software.
It is general-purpose software. While it’s a specific purpose software.
Without system software, the system stops and
can’t run.
While Without application software system always
runs.
System software runs when the system is turned
on and stops when the system is turned off.
While application software runs as per the user’s
request.
Example: System software is an operating system,
etc.
Example: Application software is Photoshop, VLC
player, etc.
System software module 1 presentation file
Assembler
• Assembler can be defined as a program that translates an assembly language
program into a machine language program.
• An assembler inputs a program written in assembly language, and translates
all of the symbols in the input into numeric values, creating an output object
module, suitable for loading.
• If an assembler which runs on a computer and produces the machine codes
for the same computer then it is called self assembler or resident assembler.
• If an assembler that runs on a computer and produces the machine codes for
other computer then it is called Cross Assembler.
• if assembler do all this work in one scan then it is called single pass
assembler, otherwise if it does in multiple scans then called multiple pass
assembler/Two-Pass Assembler
• Assembler is a computer program which is used to translate program
written in Assembly Language in to machine language.
• The translated program is called as object program.
• Assembler checks each instruction for its correctness and generates
diagnostic messages, if there are mistakes in the program.
Various steps of assembling are:
1. Input source program in Assembly Language through an input
device.
2. Use Assembler to produce object program in machine language.
3. Execute the program.
Data Structure
An assembler must translate two different kinds of symbols:
Assembler-defined symbols and programmer-defined symbols.
The assembler-defined symbols are mnemonics for the machine
instructions and pseudo-instructions.
Programmer-defined symbols are the symbols which the programmer
defines in the label field of statements in program.
These two kinds of symbols are translated by two different tables: the
opcode table, and the symbol table.
 Opcode table: They store the value of mnemonics and their corresponding
numeric values.
 Symbol table: They store the value of programming language symbols
used by the programmer, and their corresponding numeric values.
• The other data structures differ from assembler to assembler, depending
upon the design of the assembly language and the assembler.
• One variable in particular is important. This is the location counter. The
location counter is a variable which stores the address of the location into
which the current instruction is to be loaded.
General Flow of An Assembler
 Each input assembly statement, each card, is handled separately, so our
most general flow would be simply, "Process each card until an END
pseudo-instruction is found.“
1. Read in a card.
2. If the card is a comment (column 1 is an "*") then skip over
processing to step 4 for printing.
3. For non-comment cards, get the opcode and search the opcode table
for it. Using the type field of the opcode table entry, process this
card.
4. After the card has been processed, print a line of listing for this card.
5. If the opcode was not an END pseudo-instruction, go back to step 1
to process the next card.
System software module 1 presentation file
Two pass assemblers
• A two-pass assembler makes two passes over the input program. That
is, it reads the program twice.
• the first pass constructs the symbol table; the second pass generates
object code.
• This causes a major change in the basic flow of an assembler, and
results in another important data structure: the intermediate text.
• Notice that, the machine language code is not produced until pass 2,
the assembly listing is not produced until pass 2.
• The intermediate text can be stored in several ways. The best storage
location would be in main memory. – memory size problms arrive
• A more common solution is to store the intermediate text on a
secondary storage device, such as tape, drum, or disk.
One pass assemblers
• A one- pass assembler does everything in one pass through the program.
• The only problem with a one-pass assembler is caused by forward
references.
• The solutions to this problem are : Use-tables or Chaining.
• the address field cannot always be defined. Thus, some later program
must fix-up those instructions with forward reference.
• In a two-pass assembler, this program is pass 2. In a one- pass assembler,
there is no second pass, and so the program which must fix-up the
forward references is the loader.
• The loader resolves forward references for a one-pass assembler.
• Use-tables :
• the assembler keeps track of all forward references to each symbol.
• After the value of the symbol is defined, the assembler generates
special loader instructions to tell the loader the addresses of all
forward references to a symbol and its correct value.
• When the loader encounters these special instructions during loading,
it will fix-up the address field of the forward reference instruction to
have the correct value.
Chaining :
• Only the address of the most recent use must be kept.
• When a symbol is defined which has been forward referenced, special
instructions are again issued to the loader to fix-up the chains which have
been produced.
A one-pass assembler generates its object code for the loader in such a way
that the loader, or the loaded program itself, will fix-up forward references.
• Pass-1:
• Define symbols and literals and remember them in symbol table
and literal table respectively.
• Keep track of location counter
• Process pseudo-operations
• Defines program that assigns the memory addresses to
the variables and translates the source code into machine code
• Pass-2:
• Generate object code by converting symbolic op-code into
respective numeric op-code
• Generate data for literals and look for values of symbols
• Defines program which reads the source code two times
• It reads the source code and translates the code into object code.
LOADERS
• Loader is a program that loads machine codes of a program into the system
memory.
• Loading a program involves reading the contents of executable file into
memory.
• Once loading is complete, the operating system starts the program by passing
control to the loaded program code.
• In many operating systems the loader is permanently resident in memory.
Functions:
1. Allocation
2. Linking
3. Relocation
4. Loading
1. Allocation:
• Allocates the space (by calculating the size of the program) in the
memory where the object program would be loaded for Execution.
• In absolute loader allocation is done by the programmer and hence it is
the duty of the programmer to ensure that the programs do not get
overlap.
• In reloadable loader allocation is done by the loader hence the
assembler must supply the loader the size of the program.
2. Linking:
• It links two or more object codes and provides the information needed to allow
references between them.
• assigning all the user subroutine and library subroutine addresses. This activity
is called linking.
• In absolute loader linking is done by the programmer as the programmer is
aware about the runtime address of the symbols.
• In relocatable loader, linking is done by the loader and hence the assembler
must supply to the loader, the locations at which the loading is to be done.
3. Relocation:
• It modifies the object program by changing the address of program.
• There are some address dependent locations in the program, such address
constants must be adjusted according to allocated space, such activity
done by loader is called relocation.
• In absolute Loader relocation is done by the assembler as the assembler is
aware of the starting address of the program.
• In relocatable loader relocation is done by the loader and hence assembler
must supply to the loader the location at which relocation is to be done.
4. Loading:
• It brings the object program into the memory for execution.
• Finally it places all the machine instructions and data of corresponding
programs and subroutines into the memory.
• Thus program now becomes ready for execution, this activity is called
loading.
• In both the loaders (absolute, relocatable) Loading is done by the loader
and hence the assembler must supply to the loader the object program.
LINKERS:
• In high level languages, some built in header files or libraries are stored.
• These libraries are predefined and these contain basic functions which are
linked to the libraries by a program called Linker.
• If linker does not find a library of a function then it informs to compiler and
then compiler generates an error.
• The compiler automatically invokes the linker as the last step in compiling a
program.
• In computer science, a linker is a computer program that takes one or
more object files generated by a compiler and combines them into one,
executable program.
Types:
1. Static Linking – It is performed during the compilation of source
program. Linking is performed before execution in static linking.
• The linker copies all library routines used in the program into executable
image. As a result, it requires more memory space.
• As it does not require the presence of library on the system when it is
run, so it is faster and more portable.
• No failure chance and less error chance.
2. Dynamic linking – Dynamic linking is performed during the run time.
• This linking is accomplished by placing the name of a shareable library in
the executable image.
• There are more chances of errors and failures.
• It require less memory space as multiple programs can share a single
copy of the library. Here we can perform code sharing.
• It fixes the address at run time.
MACROS
• Macros are used to make a sequence of computing instructions available to
the programmer as a single program statement.
• In assembler language, a macro definition defines how to expand a single
language statement or computer instruction into a number of instructions.
Macros are useful for the following purposes:
To simplify and reduce the amount of repetitive coding
To reduce errors caused by repetitive coding
To make an assembly program more readable.
• A macro consists of name, set of formal parameters and body of code.
• The use of macro name with set of actual parameters is replaced by some code
generated by its body. This is called macro expansion.
For instance,
#define max (a, b) a>b? A: b
Defines the macro max, taking two arguments a and b. This macro may be called
like any C function, using identical syntax. Therefore, after preprocessing
z = max(x, y);
Becomes
z = x>y? X:y;
COMPILERS
• A compiler is a program that translates a programme written in HLL to
executable machine language.
• When executing (running), the compiler first parses (or analyzes) all
of the language statements syntactically one after the other and then, in
one or more successive stages or "passes", builds the output code.
• the output of the compilation has been called object code or sometimes
an object module.
System software module 1 presentation file
Job of a complier
1. To translate HLL source program to machine codes.
2. To trace variables in the program
3. To include linkage for subroutines.
4. To allocate memory for storage of program and variables.
5. To generate error messages, if there are errors in the program.
Important phases in Compilation
1. Lexical Analysis
• Generally in an HLL there are more number of tokens to be recognised - various
keywords (such as for, while, if, else, etc.), punctuation symbols (such as comma,
semi- colon, braces, etc.), operators (such as arithmetic operators, logical operators,
etc.), identifiers, etc.
• Tools like lex or flex are used to create lexical analyzers.
2. Syntax Analysis
• Syntax analysis deals with recognizing the structure of input programs according to
known set of syntax rules defined for the HLL.
• In case of HLLs, the syntax rules are much more complicated.
3. Intermediate Code Generation
• Having recognized a given input program as valid, a compiler tries to create the equivalent
program in the language of the target environment.
4. Code Optimization
• The programs represented in the intermediate code form usually contains much scope for
optimization both in terms of storage space as well as run time efficiency of the intended output
program.
• Hence, compilers usually implement explicit steps to optimize the intermediate code.
5. Code Generation
• Finally, the compiler converts the (optimized) program in the intermediate code representation to
the required machine language.
• It needs to be noted that if the program being translated by the compiler actually has
dependencies on some external modules, and then linking has to be performed to the output of
the compiler.
System software module 1 presentation file
INTERPRETERS
• An interpreter is a program which translates statements of a program into machine
code.
• It translates only one statement of the program at a time. It reads only one
statement of program, translates it and executes it.
• By the compiler, the machine codes are saved permanently for future reference.
On the other hand, the machine codes produced by interpreter are not saved.
• An interpreter is a small program as compared to compiler. It occupies less
memory space, so it can be used in a smaller system which has limited memory
space.
System software module 1 presentation file
OPERATING SYSTEM
• An operating system (OS) is the program that, after being initially
loaded into the computer by a boot program, manages all the other
programs in a computer.
• The application programs make use of the operating system by
making requests for services through application program interface
(API).
• users can interact directly with the operating system through a user
interface such as a command line or a graphical user interface (GUI).
• Services of An operating system
1. Memory Management
2. Process Management
3. Processor Management
4. Device Management
5. File Management
6. Security
7. Control over system performance
8. Job accounting
9. Error detecting aids
10.Coordination between other software and users
11.Free Space management
• An Operating System (OS) is an interface between computer user and
computer hardware.
1. Memory Management
• Keeps tracks of primary memory, i.e., what part of it are in use by
whom, what part are not in use.
• In multiprogramming, the OS decides which process will get memory
when and how much.
• Allocates the memory when a process requests it to do so.
• De-allocates the memory when a process no longer needs it or has
been terminated.
2. Processor Management
In multiprogramming environment, the OS decides which process
gets the processor when and for how much time. This function is
called process scheduling.
• Keeps tracks of processor and status of process. The program
responsible for this task is known as traffic controller.
• Allocates the processor (CPU) to a process.
• De-allocates processor when a process is no longer required.
3.Device Management
• Keeps tracks of all devices. Program responsible for this task is known as
the I/O controller.
• Decides which process gets the device when and for how much time.
• Allocates the device in the efficient way & De-allocates devices.
4.File Management
• Keeps track of information, location, uses, status etc. The collective
facilities are often known as file system.
• Decides who gets the resources.
• Allocates & De-allocates the resources.
Other Important Activities
• Security − By means of password and similar other techniques, it
prevents unauthorized access to programs and data.
• Control over system performance − Recording delays between
request for a service and response from the system.
• Job accounting − Keeping track of time and resources used by various
jobs and users.
• Error detecting aids − Production of dumps, traces, error messages,
and other debugging and error detecting aids.
• Coordination between other softwares and users − Coordination and
assignment of compilers, interpreters, assemblers and other software
to the various users of the computer systems.
Types of Operating Systems
1. Batch operating system
2. Time-sharing operating systems
3. Distributed operating System
4. Network operating System
5. Real Time operating System
6. Multi-Programming Operating System
7. Multiprocessing Operating System:
DESIGN PROCEDURE OF A TWO-PASS ASSEMBLER
• The general design procedure of an assembler involves the following
six steps:
1. Specification of the problem
2. Specification of the data structures
3. Defining the format of data structures
4. Specifying the algorithm
5. Looking for modularity that ensures the capability of a program to
be subdivided into independent programming units
6. Repeating step 1 to 5 on modules for accuracy and checking errors.
A two-pass assembler includes two passes, Pass1 and Pass 2.
In Pass 1 of the two-pass assembler, the assembler reads the assembly
source program. Each instruction in the program is processed and is
then translated to the generator.
These translations are accumulated in appropriate tables, which help
fetch a stored value.
 In addition to this, an intermediate form of each statement is
generated.
Once these translations have been made, Pass 2 starts its operation.
Functions that are performed by an assembler while translating a
program:
• It replaces symbolic addresses with numeric addresses.
• It replaces symbolic operation codes with machine operation codes.
• It reserves storage for instructions and data.
• It translates constants into machine representation.
• The primary aim of the first pass of a two-pass assembler is to draw
up a symbol table.
• Once Pass 1 has been completed, all necessary information on each
user-defined identifier should have been recorded in this table.
• The first pass can also perform some error checking.
An assembler designer is responsible for creating OPTAB table.
Once the table is created, an assembler can use the tables contained
within OPTAB, known as sub tables. These sub-tables include
mnemonics and their translations.
The OPTAB table contains:
• Content: mnemonic, machine code (instruction format, length), etc.
• Characteristic: static table, and
• Implementation: array or hash table, easy for search.
Another type of tables used in the two-pass assembler is the symbol
table. The symbol table is denoted by SYMTAB.
This table stores the symbols that are user-defined in the assembly
program. These symbols may be identifiers, constants or labels.
 The SYMTAB table contains:
• Content: label name, value, flag, (type, length), etc.
• Characteristic: dynamic table (insert, delete, search), and
• Implementation: hash table, non-random keys, hashing function.
System software module 1 presentation file
System software module 1 presentation file
System software module 1 presentation file

More Related Content

PPTX
Compiler Design Introduction
PPT
Introduction to compiler design and phases of compiler
PPTX
Compiler Design Introduction With Design
PPTX
System Programing Unit 1
PPTX
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
PDF
Namdeo Kapale Sanjivani College of Engineering KopaCFP_UNIT1_24-25.pdf
PPTX
CD module 1.pptx Introduction to compiler Design
PPTX
Compiler an overview
Compiler Design Introduction
Introduction to compiler design and phases of compiler
Compiler Design Introduction With Design
System Programing Unit 1
PCSG_Computer_Science_Unit_1_Lecture_2.pptx
Namdeo Kapale Sanjivani College of Engineering KopaCFP_UNIT1_24-25.pdf
CD module 1.pptx Introduction to compiler Design
Compiler an overview

Similar to System software module 1 presentation file (20)

PPTX
Chapter 1.pptx
PPTX
Compiler Construction from very basic start
PPTX
Phases of Compiler
PPTX
COMPILER DESIGN PPTS.pptx
PPTX
Unit1 111206003944-phpapp02
PDF
Hm system programming class 1
PPTX
Pros and cons of c as a compiler language
PDF
Embedded systems designUNIT 4 PART 2.pdf
PPT
Concept of compiler in details
DOCX
Interaction With Computers FIT
PPTX
Phases of Compiler.pptx
PDF
Week 08_Basics of Compiler Construction.pdf
PDF
Chapter1.pdf
PPT
01CHAP_1.PPT
PPT
Chap01-Intro.ppt
PPTX
Bba i-introduction to computer-u-2- application and system software
PPTX
Mca i-fundamental of computer-u-2- application and system software
PPTX
Bca i-fundamental of computer-u-2- application and system software
PDF
Module4.pdf ,...................................
PPTX
Introduction to Computer Softwares
Chapter 1.pptx
Compiler Construction from very basic start
Phases of Compiler
COMPILER DESIGN PPTS.pptx
Unit1 111206003944-phpapp02
Hm system programming class 1
Pros and cons of c as a compiler language
Embedded systems designUNIT 4 PART 2.pdf
Concept of compiler in details
Interaction With Computers FIT
Phases of Compiler.pptx
Week 08_Basics of Compiler Construction.pdf
Chapter1.pdf
01CHAP_1.PPT
Chap01-Intro.ppt
Bba i-introduction to computer-u-2- application and system software
Mca i-fundamental of computer-u-2- application and system software
Bca i-fundamental of computer-u-2- application and system software
Module4.pdf ,...................................
Introduction to Computer Softwares
Ad

Recently uploaded (20)

PDF
Skskkxiixijsjsnwkwkaksixindndndjdjdjsjjssk
PPT
Machine printing techniques and plangi dyeing
PDF
Interior Structure and Construction A1 NGYANQI
PPTX
HPE Aruba-master-icon-library_052722.pptx
PPTX
Entrepreneur intro, origin, process, method
PPTX
mahatma gandhi bus terminal in india Case Study.pptx
PPTX
An introduction to AI in research and reference management
PPT
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
PDF
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
PDF
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
DOCX
actividad 20% informatica microsoft project
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
PPTX
Fundamental Principles of Visual Graphic Design.pptx
PDF
SEVA- Fashion designing-Presentation.pdf
PPTX
DOC-20250430-WA0014._20250714_235747_0000.pptx
PPTX
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
PDF
Quality Control Management for RMG, Level- 4, Certificate
PDF
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
PDF
Design Thinking - Module 1 - Introduction To Design Thinking - Dr. Rohan Dasg...
PPT
UNIT I- Yarn, types, explanation, process
Skskkxiixijsjsnwkwkaksixindndndjdjdjsjjssk
Machine printing techniques and plangi dyeing
Interior Structure and Construction A1 NGYANQI
HPE Aruba-master-icon-library_052722.pptx
Entrepreneur intro, origin, process, method
mahatma gandhi bus terminal in india Case Study.pptx
An introduction to AI in research and reference management
EGWHermeneuticsffgggggggggggggggggggggggggggggggg.ppt
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
Integrated-2D-and-3D-Animation-Bridging-Dimensions-for-Impactful-Storytelling...
actividad 20% informatica microsoft project
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
Fundamental Principles of Visual Graphic Design.pptx
SEVA- Fashion designing-Presentation.pdf
DOC-20250430-WA0014._20250714_235747_0000.pptx
ANATOMY OF ANTERIOR CHAMBER ANGLE AND GONIOSCOPY.pptx
Quality Control Management for RMG, Level- 4, Certificate
Facade & Landscape Lighting Techniques and Trends.pptx.pdf
Design Thinking - Module 1 - Introduction To Design Thinking - Dr. Rohan Dasg...
UNIT I- Yarn, types, explanation, process
Ad

System software module 1 presentation file

  • 2. Module 1 •System software: General concept, Assemblers, loaders, linkers, macros, compilers, interpreters, operating system, Design of assemblers
  • 3. • System software is a program designed to run a computer's hardware and applications and manage its resources, such as its memory, processors, and devices.
  • 4. What is System Software? • System software is software that provides a platform for other software. • Some examples can be operating systems, antivirus software, disk formatting software, computer language translators, etc. • These are commonly prepared by computer manufacturers. • This software consists of programs written in low-level languages, used to interact with the hardware at a very basic level. • It acts as an intermediary between the user and the computer hardware, allowing the user to interact with the hardware and use various applications and programs.
  • 5. Why use System Software? • Hardware Communication • Resource Management • Security • User Interface • Application Support • Customization Operating systems are the most important type of system software, as they provide the foundational framework for all other software and applications to run on the computer.
  • 6. Features of System Software • Memory Management: The OS keeps track of the primary memory and allocates the memory when a process requests it. • Processor Management: Allocates the main memory (RAM) to a process and de-allocates it when it is no longer required. • File Management: Allocates and de-allocates the resources and decides who gets the resources. • Security: Prevents unauthorized access to programs and data using passwords. • Error-detecting Aids: Production of dumps, traces, error messages, and other debugging and error-detecting methods. • Scheduling: The OS schedules the process through its scheduling algorithms.
  • 7. Types of System Software
  • 9. System Software Application Software System Software maintains the system resources and gives the path for application software to run. Application software is built for specific tasks. Low-level languages are used to write the system software. While high-level languages are used to write the application software. It is general-purpose software. While it’s a specific purpose software. Without system software, the system stops and can’t run. While Without application software system always runs. System software runs when the system is turned on and stops when the system is turned off. While application software runs as per the user’s request. Example: System software is an operating system, etc. Example: Application software is Photoshop, VLC player, etc.
  • 11. Assembler • Assembler can be defined as a program that translates an assembly language program into a machine language program. • An assembler inputs a program written in assembly language, and translates all of the symbols in the input into numeric values, creating an output object module, suitable for loading. • If an assembler which runs on a computer and produces the machine codes for the same computer then it is called self assembler or resident assembler. • If an assembler that runs on a computer and produces the machine codes for other computer then it is called Cross Assembler. • if assembler do all this work in one scan then it is called single pass assembler, otherwise if it does in multiple scans then called multiple pass assembler/Two-Pass Assembler
  • 12. • Assembler is a computer program which is used to translate program written in Assembly Language in to machine language. • The translated program is called as object program. • Assembler checks each instruction for its correctness and generates diagnostic messages, if there are mistakes in the program. Various steps of assembling are: 1. Input source program in Assembly Language through an input device. 2. Use Assembler to produce object program in machine language. 3. Execute the program.
  • 13. Data Structure An assembler must translate two different kinds of symbols: Assembler-defined symbols and programmer-defined symbols. The assembler-defined symbols are mnemonics for the machine instructions and pseudo-instructions. Programmer-defined symbols are the symbols which the programmer defines in the label field of statements in program. These two kinds of symbols are translated by two different tables: the opcode table, and the symbol table.
  • 14.  Opcode table: They store the value of mnemonics and their corresponding numeric values.  Symbol table: They store the value of programming language symbols used by the programmer, and their corresponding numeric values. • The other data structures differ from assembler to assembler, depending upon the design of the assembly language and the assembler. • One variable in particular is important. This is the location counter. The location counter is a variable which stores the address of the location into which the current instruction is to be loaded.
  • 15. General Flow of An Assembler  Each input assembly statement, each card, is handled separately, so our most general flow would be simply, "Process each card until an END pseudo-instruction is found.“ 1. Read in a card. 2. If the card is a comment (column 1 is an "*") then skip over processing to step 4 for printing. 3. For non-comment cards, get the opcode and search the opcode table for it. Using the type field of the opcode table entry, process this card. 4. After the card has been processed, print a line of listing for this card. 5. If the opcode was not an END pseudo-instruction, go back to step 1 to process the next card.
  • 17. Two pass assemblers • A two-pass assembler makes two passes over the input program. That is, it reads the program twice. • the first pass constructs the symbol table; the second pass generates object code. • This causes a major change in the basic flow of an assembler, and results in another important data structure: the intermediate text.
  • 18. • Notice that, the machine language code is not produced until pass 2, the assembly listing is not produced until pass 2. • The intermediate text can be stored in several ways. The best storage location would be in main memory. – memory size problms arrive • A more common solution is to store the intermediate text on a secondary storage device, such as tape, drum, or disk.
  • 19. One pass assemblers • A one- pass assembler does everything in one pass through the program. • The only problem with a one-pass assembler is caused by forward references. • The solutions to this problem are : Use-tables or Chaining. • the address field cannot always be defined. Thus, some later program must fix-up those instructions with forward reference. • In a two-pass assembler, this program is pass 2. In a one- pass assembler, there is no second pass, and so the program which must fix-up the forward references is the loader. • The loader resolves forward references for a one-pass assembler.
  • 20. • Use-tables : • the assembler keeps track of all forward references to each symbol. • After the value of the symbol is defined, the assembler generates special loader instructions to tell the loader the addresses of all forward references to a symbol and its correct value. • When the loader encounters these special instructions during loading, it will fix-up the address field of the forward reference instruction to have the correct value.
  • 21. Chaining : • Only the address of the most recent use must be kept. • When a symbol is defined which has been forward referenced, special instructions are again issued to the loader to fix-up the chains which have been produced. A one-pass assembler generates its object code for the loader in such a way that the loader, or the loaded program itself, will fix-up forward references.
  • 22. • Pass-1: • Define symbols and literals and remember them in symbol table and literal table respectively. • Keep track of location counter • Process pseudo-operations • Defines program that assigns the memory addresses to the variables and translates the source code into machine code • Pass-2: • Generate object code by converting symbolic op-code into respective numeric op-code • Generate data for literals and look for values of symbols • Defines program which reads the source code two times • It reads the source code and translates the code into object code.
  • 23. LOADERS • Loader is a program that loads machine codes of a program into the system memory. • Loading a program involves reading the contents of executable file into memory. • Once loading is complete, the operating system starts the program by passing control to the loaded program code. • In many operating systems the loader is permanently resident in memory.
  • 24. Functions: 1. Allocation 2. Linking 3. Relocation 4. Loading
  • 25. 1. Allocation: • Allocates the space (by calculating the size of the program) in the memory where the object program would be loaded for Execution. • In absolute loader allocation is done by the programmer and hence it is the duty of the programmer to ensure that the programs do not get overlap. • In reloadable loader allocation is done by the loader hence the assembler must supply the loader the size of the program.
  • 26. 2. Linking: • It links two or more object codes and provides the information needed to allow references between them. • assigning all the user subroutine and library subroutine addresses. This activity is called linking. • In absolute loader linking is done by the programmer as the programmer is aware about the runtime address of the symbols. • In relocatable loader, linking is done by the loader and hence the assembler must supply to the loader, the locations at which the loading is to be done.
  • 27. 3. Relocation: • It modifies the object program by changing the address of program. • There are some address dependent locations in the program, such address constants must be adjusted according to allocated space, such activity done by loader is called relocation. • In absolute Loader relocation is done by the assembler as the assembler is aware of the starting address of the program. • In relocatable loader relocation is done by the loader and hence assembler must supply to the loader the location at which relocation is to be done.
  • 28. 4. Loading: • It brings the object program into the memory for execution. • Finally it places all the machine instructions and data of corresponding programs and subroutines into the memory. • Thus program now becomes ready for execution, this activity is called loading. • In both the loaders (absolute, relocatable) Loading is done by the loader and hence the assembler must supply to the loader the object program.
  • 29. LINKERS: • In high level languages, some built in header files or libraries are stored. • These libraries are predefined and these contain basic functions which are linked to the libraries by a program called Linker. • If linker does not find a library of a function then it informs to compiler and then compiler generates an error. • The compiler automatically invokes the linker as the last step in compiling a program.
  • 30. • In computer science, a linker is a computer program that takes one or more object files generated by a compiler and combines them into one, executable program.
  • 31. Types: 1. Static Linking – It is performed during the compilation of source program. Linking is performed before execution in static linking. • The linker copies all library routines used in the program into executable image. As a result, it requires more memory space. • As it does not require the presence of library on the system when it is run, so it is faster and more portable. • No failure chance and less error chance.
  • 32. 2. Dynamic linking – Dynamic linking is performed during the run time. • This linking is accomplished by placing the name of a shareable library in the executable image. • There are more chances of errors and failures. • It require less memory space as multiple programs can share a single copy of the library. Here we can perform code sharing. • It fixes the address at run time.
  • 33. MACROS • Macros are used to make a sequence of computing instructions available to the programmer as a single program statement. • In assembler language, a macro definition defines how to expand a single language statement or computer instruction into a number of instructions. Macros are useful for the following purposes: To simplify and reduce the amount of repetitive coding To reduce errors caused by repetitive coding To make an assembly program more readable.
  • 34. • A macro consists of name, set of formal parameters and body of code. • The use of macro name with set of actual parameters is replaced by some code generated by its body. This is called macro expansion. For instance, #define max (a, b) a>b? A: b Defines the macro max, taking two arguments a and b. This macro may be called like any C function, using identical syntax. Therefore, after preprocessing z = max(x, y); Becomes z = x>y? X:y;
  • 35. COMPILERS • A compiler is a program that translates a programme written in HLL to executable machine language. • When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically one after the other and then, in one or more successive stages or "passes", builds the output code. • the output of the compilation has been called object code or sometimes an object module.
  • 37. Job of a complier 1. To translate HLL source program to machine codes. 2. To trace variables in the program 3. To include linkage for subroutines. 4. To allocate memory for storage of program and variables. 5. To generate error messages, if there are errors in the program.
  • 38. Important phases in Compilation 1. Lexical Analysis • Generally in an HLL there are more number of tokens to be recognised - various keywords (such as for, while, if, else, etc.), punctuation symbols (such as comma, semi- colon, braces, etc.), operators (such as arithmetic operators, logical operators, etc.), identifiers, etc. • Tools like lex or flex are used to create lexical analyzers. 2. Syntax Analysis • Syntax analysis deals with recognizing the structure of input programs according to known set of syntax rules defined for the HLL. • In case of HLLs, the syntax rules are much more complicated.
  • 39. 3. Intermediate Code Generation • Having recognized a given input program as valid, a compiler tries to create the equivalent program in the language of the target environment. 4. Code Optimization • The programs represented in the intermediate code form usually contains much scope for optimization both in terms of storage space as well as run time efficiency of the intended output program. • Hence, compilers usually implement explicit steps to optimize the intermediate code. 5. Code Generation • Finally, the compiler converts the (optimized) program in the intermediate code representation to the required machine language. • It needs to be noted that if the program being translated by the compiler actually has dependencies on some external modules, and then linking has to be performed to the output of the compiler.
  • 41. INTERPRETERS • An interpreter is a program which translates statements of a program into machine code. • It translates only one statement of the program at a time. It reads only one statement of program, translates it and executes it. • By the compiler, the machine codes are saved permanently for future reference. On the other hand, the machine codes produced by interpreter are not saved. • An interpreter is a small program as compared to compiler. It occupies less memory space, so it can be used in a smaller system which has limited memory space.
  • 43. OPERATING SYSTEM • An operating system (OS) is the program that, after being initially loaded into the computer by a boot program, manages all the other programs in a computer. • The application programs make use of the operating system by making requests for services through application program interface (API). • users can interact directly with the operating system through a user interface such as a command line or a graphical user interface (GUI).
  • 44. • Services of An operating system 1. Memory Management 2. Process Management 3. Processor Management 4. Device Management 5. File Management 6. Security 7. Control over system performance 8. Job accounting 9. Error detecting aids 10.Coordination between other software and users 11.Free Space management
  • 45. • An Operating System (OS) is an interface between computer user and computer hardware.
  • 46. 1. Memory Management • Keeps tracks of primary memory, i.e., what part of it are in use by whom, what part are not in use. • In multiprogramming, the OS decides which process will get memory when and how much. • Allocates the memory when a process requests it to do so. • De-allocates the memory when a process no longer needs it or has been terminated.
  • 47. 2. Processor Management In multiprogramming environment, the OS decides which process gets the processor when and for how much time. This function is called process scheduling. • Keeps tracks of processor and status of process. The program responsible for this task is known as traffic controller. • Allocates the processor (CPU) to a process. • De-allocates processor when a process is no longer required.
  • 48. 3.Device Management • Keeps tracks of all devices. Program responsible for this task is known as the I/O controller. • Decides which process gets the device when and for how much time. • Allocates the device in the efficient way & De-allocates devices. 4.File Management • Keeps track of information, location, uses, status etc. The collective facilities are often known as file system. • Decides who gets the resources. • Allocates & De-allocates the resources.
  • 49. Other Important Activities • Security − By means of password and similar other techniques, it prevents unauthorized access to programs and data. • Control over system performance − Recording delays between request for a service and response from the system. • Job accounting − Keeping track of time and resources used by various jobs and users. • Error detecting aids − Production of dumps, traces, error messages, and other debugging and error detecting aids. • Coordination between other softwares and users − Coordination and assignment of compilers, interpreters, assemblers and other software to the various users of the computer systems.
  • 50. Types of Operating Systems 1. Batch operating system 2. Time-sharing operating systems 3. Distributed operating System 4. Network operating System 5. Real Time operating System 6. Multi-Programming Operating System 7. Multiprocessing Operating System:
  • 51. DESIGN PROCEDURE OF A TWO-PASS ASSEMBLER • The general design procedure of an assembler involves the following six steps: 1. Specification of the problem 2. Specification of the data structures 3. Defining the format of data structures 4. Specifying the algorithm 5. Looking for modularity that ensures the capability of a program to be subdivided into independent programming units 6. Repeating step 1 to 5 on modules for accuracy and checking errors.
  • 52. A two-pass assembler includes two passes, Pass1 and Pass 2. In Pass 1 of the two-pass assembler, the assembler reads the assembly source program. Each instruction in the program is processed and is then translated to the generator. These translations are accumulated in appropriate tables, which help fetch a stored value.  In addition to this, an intermediate form of each statement is generated. Once these translations have been made, Pass 2 starts its operation. Functions that are performed by an assembler while translating a program: • It replaces symbolic addresses with numeric addresses. • It replaces symbolic operation codes with machine operation codes. • It reserves storage for instructions and data. • It translates constants into machine representation.
  • 53. • The primary aim of the first pass of a two-pass assembler is to draw up a symbol table. • Once Pass 1 has been completed, all necessary information on each user-defined identifier should have been recorded in this table. • The first pass can also perform some error checking.
  • 54. An assembler designer is responsible for creating OPTAB table. Once the table is created, an assembler can use the tables contained within OPTAB, known as sub tables. These sub-tables include mnemonics and their translations. The OPTAB table contains: • Content: mnemonic, machine code (instruction format, length), etc. • Characteristic: static table, and • Implementation: array or hash table, easy for search.
  • 55. Another type of tables used in the two-pass assembler is the symbol table. The symbol table is denoted by SYMTAB. This table stores the symbols that are user-defined in the assembly program. These symbols may be identifiers, constants or labels.  The SYMTAB table contains: • Content: label name, value, flag, (type, length), etc. • Characteristic: dynamic table (insert, delete, search), and • Implementation: hash table, non-random keys, hashing function.