0% found this document useful (0 votes)
97 views8 pages

SPOS Unit-1 Simple Notes

Uploaded by

tanujam0606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views8 pages

SPOS Unit-1 Simple Notes

Uploaded by

tanujam0606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Systems Programming and Operating System www.sppuengineers.

site

310243 – Systems Programming and Operating System


(2019 Pattern) (Semester - V)

Unit 1 Introduction Marks


Introduction to Systems Programming, Need of systems programming, Software
Hierarchy, Types ofsoftware: system software and application software, Machine
structure.Evolution of components of systems programming: Text Editors,
Assembler,Macros, Compiler, Interpreter, Loader, Linker, Debugger, Device Drivers,
Operating System.Elements of Assembly Language Programming: Assembly 15
Language statements, Benefits of Assembly Language, A simple Assembly scheme,
Pass Structure of Assembler.Design of two pass assembler: Processing of declaration
statements, Assembler Directives an imperative statements, Advanced Assembler
Directives, Intermediate code forms, Pass I and Pass II of two pass Assembler.

1. Introduction to Systems Programming and its Necessity

What is Systems Programming?

Systems programming is the discipline of designing and writing computer programs that
allow the computer hardware to function and provide a platform for application software
to run. It is the art of creating the foundational layer of software that manages the system's
resources. These programs are often called system software.

Think of it as building the infrastructure of a city. Before you can build houses, offices,
and parks (application software), you need to build roads, power grids, water supply
systems, and a government (system software). This infrastructure makes the city livable
and functional. Similarly, systems programming creates the "digital infrastructure" for all
other programs.

Why is Systems Programming Necessary?

Without systems programming, every application developer would face an insurmountable


task:

• Direct Hardware Management: A programmer would need to manually control


the CPU's registers, manage memory addresses, send specific voltage signals to I/O
devices, and handle interrupts directly. This is incredibly complex, tedious, and
prone to errors.
• Resource Contention: If multiple programs were running, they would have no
coordinated way to share the CPU, memory, or peripherals. They would conflict
with each other, leading to system crashes.

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 1


Systems Programming and Operating System www.sppuengineers.site

• Lack of Abstraction: There would be no simplified way to perform common tasks


like reading a file or displaying text on the screen. Programmers would have to
rewrite the complex, low-level code for these tasks in every single application.
• No Portability: A program written for one specific model of computer would not
work on any other, as it would be tied to that exact hardware configuration.

Systems programming solves these problems by providing a crucial layer


of abstraction, resource management, and portability.

2. Software Hierarchy

Software is not monolithic; it's organized in layers, with each layer relying on the services
of the one below it. This is known as the software hierarchy.

Analogy: The Restaurant

• Layer 0: Hardware: The physical kitchen—the stove, ovens, refrigerators, knives,


and pans. This is the fundamental, physical infrastructure.
• Layer 1: System Software (The Kitchen Staff & Management):
o Operating System: The Head Chef and Kitchen Manager who directs all the
staff, decides who uses which stove (CPU scheduling), manages the pantry
inventory (memory management), and ensures health and safety rules are
followed (security).
o Compilers, Linkers, Loaders: The prep cooks who take a chef's recipe
(source code) and turn it into ready-to-cook components (executable code).
o Device Drivers: The specialized staff who know exactly how to operate the
new Italian espresso machine (a specific hardware device).

• Layer 2: Application Software (The Dishes): These are the final products that the
customer (user) orders and consumes—a steak, a salad, a dessert. Each is designed
for a specific purpose (to be eaten). They rely entirely on the kitchen and its staff to
be created.

• Layer 3: User: The customer who enjoys the meal without needing to know how
the stove works or how the inventory is managed.

This layered approach ensures a separation of concerns, making the entire system more
manageable, efficient, and easier to develop for.

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 2


Systems Programming and Operating System www.sppuengineers.site

3. Types of Software: System vs. Application

System Software

• Purpose: To manage and control the computer hardware and to provide a platform
for running application software. It operates in the background.
• Interaction: Generally, users do not interact with system software directly. Its
primary "customer" is other software.
• Essentiality: It is essential for the basic functioning of a computer. A computer
cannot run without an operating system.
• Examples:
o Operating System (OS): Windows, macOS, Linux, Android.
o Compilers & Interpreters: GCC, Clang, Python Interpreter.
o Assemblers: NASM, MASM.
o Linkers & Loaders: ld (Linux linker), Windows Loader.
o Device Drivers: NVIDIA graphics driver, Realtek audio driver.
o Utility Programs: Disk formatters, file managers.

Application Software

• Purpose: To perform specific tasks or a set of tasks for the end-user. It is what
users directly engage with to get work done or be entertained.
• Interaction: Designed for direct user interaction through a graphical user interface
(GUI) or command-line interface (CLI).
• Essentiality: It is not essential for the computer to function, but it is the reason
users have computers.
• Examples:
o Word Processors: Microsoft Word, Google Docs.
o Web Browsers: Chrome, Firefox, Safari.
o Media Players: VLC, Spotify.
o Games: Counter-Strike, The Witcher.
o Databases: MySQL, Oracle.

4. Machine Structure

To program the system, one must understand the machine's fundamental architecture,
typically the Von Neumann Architecture.

• Central Processing Unit (CPU): The "brain" of the computer that executes
instructions.
o Arithmetic Logic Unit (ALU): Performs mathematical (add, subtract) and
logical (AND, OR, NOT) operations.

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 3


Systems Programming and Operating System www.sppuengineers.site

o Control Unit (CU): Directs the flow of operations. It fetches instructions


from memory, decodes them, and directs the ALU and other components to
execute them. This is known as the fetch-decode-execute cycle.
• Main Memory (RAM): A volatile storage area that holds the instructions and data
for programs that are currently running. The CPU can access any part of RAM
directly and quickly.
• Input/Output (I/O) Devices: Peripherals used to get data into the system
(keyboard, mouse) and get results out (monitor, printer).
• Buses: A set of parallel electrical wires that act as the communication highway
connecting all the components.
o Address Bus: Carries memory addresses from the CPU to RAM.
o Data Bus: Carries the actual data between the CPU, RAM, and I/O devices.
o Control Bus: Carries control signals and timing information from the CU to
all other components.

Systems programming directly manipulates this structure to ensure efficient and correct
program execution.

5. Evolution of Components of Systems Programming

These tools evolved to make programming more efficient and powerful.

• Text Editors: The starting point. Simple tools like ed or vi, and later IDE-based
editors, allow programmers to write human-readable source code.
• Assembler: The first major step in abstraction. Instead of writing binary machine
code (e.g., 10110000 01100001), programmers could write symbolic mnemonics
(e.g., MOV AL, 61h). The assembler performs this direct translation.
• Macros: A text-replacement tool. A macro processor allows a programmer to
define a shorthand for a block of code. When the processor sees the shorthand, it
replaces it with the full block of code before assembly or compilation. This reduces
repetitive typing and errors.
• Compiler vs. Interpreter: The leap to high-level languages.

Feature Compiler Interpreter


Input Entire source code program. A single line or statement of
code.
Output A standalone executable file The immediate result of the
(object/machine code). executed statement.
Translation Translates the entire Translates and executes line-
program before execution. by-line.
Execution Faster. The code is already optimized Slower. Translation happens
Speed machine code. during runtime.

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 4


Systems Programming and Operating System www.sppuengineers.site

Error Reports all errors after scanning the Reports the first error it finds
Reporting entire program. and stops.
Example C++, Java (compiles to bytecode) Python, JavaScript

• Loader: A utility that takes the executable file from the disk and places it into the
main memory (RAM) so the CPU can start executing it.
• Linker: A utility that takes one or more object files (from the compiler/assembler)
and links them with necessary library code to produce a single, complete executable
file. It resolves references between different files.
• Debugger: An essential tool for finding and fixing bugs. It allows a programmer to
run a program in a controlled manner, set breakpoints (pausing execution at a
certain line), step through code line-by-line, and inspect the values of
variables. GDB (GNU Debugger) is a classic example.
• Device Drivers: Mini-programs that act as translators between the OS and a
specific piece of hardware. When you plug in a new graphics card, you install its
driver so the OS knows how to send it rendering commands.
• Operating System: The ultimate component, integrating all system management
tasks into a cohesive whole, managing processes, memory, files, and security.

6. Elements of Assembly Language Programming

• Assembly Language Statements: A typical line has the format:


[Label] Mnemonic [Operand(s)] ; Comment
o Label: A symbolic name for a memory address. Optional.
(e.g., LOOP_START:).
o Mnemonic: A short, easy-to-remember name for an instruction
(e.g., MOV for Move, ADD for Add).
o Operand(s): The data or memory locations the instruction operates on
(e.g., AX, BX).
o Comment: An explanation for human readers, ignored by the assembler.
• Benefits of Assembly Language:
o Speed: Code can be highly optimized for maximum execution speed.
o Space: The resulting executable can be very small.
o Direct Hardware Control: Unparalleled access to machine hardware,
essential for device drivers and embedded systems.
• Pass Structure of an Assembler: To solve the forward reference problem (using
a label like JMP AHEAD before AHEAD: is defined), assemblers use multiple
passes. A two-pass assembler is the classic design.

7. Design of a Two-Pass Assembler

The process is divided into two phases: Analysis (Pass I) and Synthesis (Pass II).

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 5


Systems Programming and Operating System www.sppuengineers.site

Core Data Structures Used:

• Location Counter (LC): A variable that holds the address of the next instruction or
data item. It's incremented as the assembler processes the code.
• Machine Opcode Table (MOT): A static table containing all instruction
mnemonics and their corresponding binary machine codes.
• Symbol Table (ST): A dynamic table built during Pass I. It stores user-defined
labels and their corresponding address values (from the LC).
• Literal Table (LT): A dynamic table built during Pass I to store literals (constants)
and assign them addresses.

Pass I: Analysis Phase

Goal: Scan the source code, populate the Symbol Table and Literal Table, and prepare an
Intermediate Representation for Pass II. The main job is to determine the address of every
label.

Algorithm:

1. Initialize the Location Counter (LC), often to the address specified by


the START directive.
2. Read the source code statement by statement.
3. For each statement:
o Check if there is a label in the [Label] field.
o If a label exists, check if it's already in the Symbol Table (ST).
▪ If it is, flag a "duplicate label" error.
▪ If not, insert the (Label, LC value) pair into the ST.
o Examine the [Mnemonic] field.
▪ If it's an assembler directive (like RESW or BYTE), update the LC
accordingly (e.g., for RESW 100, add 100 to the LC).
▪ If it's a machine instruction, update the LC by the instruction's fixed
length (e.g., 3 bytes).
4. Generate an Intermediate Code (IC) file. This file contains processed information
that Pass II will use, making the second pass simpler and faster.
5. Repeat until the END directive is encountered.

Pass II: Synthesis Phase

Goal: Use the tables created in Pass I to generate the final machine-readable object code.

Algorithm:

1. Initialize the Location Counter (LC) again.


2. Read the Intermediate Code (IC) generated by Pass I, statement by statement.
3. For each IC statement:

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 6


Systems Programming and Operating System www.sppuengineers.site

oExamine the [Mnemonic] field.


▪ If it's a machine instruction, look up its binary code in the Machine
Opcode Table (MOT).
o Examine the [Operand(s)] field.
▪ If an operand is a symbol (a label), look up its address in the Symbol
Table (ST).
▪ If an operand is a literal, look up its address in the Literal Table (LT).
o Assemble the parts—the machine opcode from MOT and the operand
addresses from ST/LT—into a complete machine instruction.
o Write this machine instruction to the object file.
o If the statement was a directive like BYTE or WORD, place the constant's
value directly into the object file.
4. Repeat until the end of the IC file is reached.

This two-pass design elegantly separates the problem of address resolution (Pass I) from
the problem of code generation (Pass II), forming the foundation of how low-level code is
translated.

Summary Points:

• Systems Programming: Creates essential software (system software) that manages


computer hardware and provides a platform for application software.
• Software Hierarchy: Software is layered, with application software relying on
system software, which in turn interacts with the hardware.
• System vs. Application Software: System software runs the computer (e.g., OS,
drivers), while application software performs user tasks (e.g., browser, word
processor).
• Machine Structure: Systems programming requires understanding core hardware
like the CPU (for executing instructions), RAM (for holding active programs), and
I/O devices.
• Evolution of Tools: Tools evolved from basic text editors and assemblers to
powerful compilers, linkers, loaders, and debuggers to make programming more
efficient.
• Assembly Language: A low-level language that provides direct hardware control
and high performance, using mnemonics for machine instructions.
• Two-Pass Assembler: A standard design to handle forward references.
o Pass I (Analysis): Scans the code to build a Symbol Table, mapping all
labels to memory addresses.
o Pass II (Synthesis): Uses the Symbol Table from Pass I to translate the
symbolic instructions into actual machine code.

Join Telegram Channel - https://t.me/sppuengineersss | @SPPU Engineers 7


Join SPPU Engineers
Community Today

📘 You’re Viewing Only Unit 1


This is a preview sample from SPPU Engineers.
To get all units, IMPs, and papers for this subject and semester:

🎁 What's Included in Full Access?


✅ All Units Notes (PDFs)
✅ Unit-wise IMP Questions
✅ Solved University Papers
✅ Drive Access Sorted by Semester & Subject
✅ Future Updates & Bonus Content
🔓 Want Full Access?
Get all study materials for this subject & semester in one place.
Limited-time offer for new users.
👉 Get Full Access Now
📢 Join Telegram Channel: https://t.me/sppuengineersss
Join SPPU Engineers Now
⭐ Trusted by 10,000+ SPPU students — making exam time
stress-free, semester after semester.

SPPU Engineer is a student-led community built to support fellow students with


simplified, well-organized study resources.
Have feedback or suggestions? Reach us anytime at [email protected]

You might also like