You are on page 1of 47

SUMMARY

CHAPTER ONE (1)


1.1 SOFTWARE: Software is a set of instruction we use to get our computer perform specific task
1.1.1 APPLICATION SOFTWARE: Application Software are program designed specifically for end-users
1.1.2 SYSTEM SOFTWARE: Ensure communication btw hardware & software also coordinate the functioning of hardware & software
1.3 PROGRAMMING: Developing & Implementing set of instructions (executable program) to enable computer do certain task
1.3.1 SYSTEM/APPLICATION PROGRAMMING: Sys Prog aim to develop software platform which provides service to other software while App
1.4 COMPILE TIME: Instance where code you entered is converted to executable. It check for errors like syntax error, typechecking error
1.5 RUN TIME: Instance where the executable is running. It check for errors that can make program behave unexpectedly

CHAPTER ONE (2)


2.1 OPERATING SYSTEM: A system that act as an interface between the user & the hardware, it coordinate & control all the resources of a comp
2.1.1 CONCEPTUAL VIEW OF AN OPERATING SYSTEM: Diagram depicting operating system layout
2.2 TYPES OF OPERATING SYSTEM: Batch, Time Sharing, Distributed, Network, Real Time etc.
2.2.1 BATCH OPERATING SYSTEM: Task are collected in batches for processing, the system performs the operation in the other of first come first
2.2.2 TIME SHARING OPERATING SYSTEM: It allows two or more program in memory to be executed simultaneously by switching btw these progra
2.2.3 DISTRIBUTED OPERATING SYSTEM: Consist of a number of computers connected together such that job processing load are shared among co
2.2.4 NETWORK OPERATING SYSTEM: An operating system that runs on a server, it provides server capabilities to manage data, users, access etc
2.2.5 REAL TIME OPERATING SYSTEM: OS that cannot afford to be late in response to an event, it must process input immediate & respond quickl
2.2.6 MULTIPROGRAMMING OPERATING SYSTEM: Allow 2 or task to reside in main memory by sharing same processor and executing processes 1
2.2.7 MULTIPROCESSING OPERATING SYSTEM: System configured to have more than one independent processing unit, two processes can be exe
2.3 FUNCTION OF AN OPERATING SYSTEM: Process Management, Memory Management, File Management, Secondary Storage Management etc
2.3.1 PROCESS MANAGEMENT: Operating System Kernel decides which of the many running programs should be allocated processor time/usage
2.3.2 MEMORY MANAGEMENT: Processes require memory to initiate, Operating system does memory allocation to processes
2.3.3 FILE MANAGEMENT: Operating System is saddled with the responsibilities of creating, track of unused space, backup, mapping file onto disk
2.3.4 SECONDARY STORAGE MANAGEMENT: Coordinate storage operations i.e how data/files are stored & accessed. Also read and written to disk
2.3.5 INPUT/OUTPUT MANAGEMENT: Manage input devices such as mouse, keyboard, scanner. Also manage output device like monitor, printer etc
2.3.6 COMMAND INTERPRETER: Allow users to interact effectively with it shell features which allows user to execute commands as control statem
2.3.7 NETWORKING: Function of networking multiple computers with the aim of sharing resources (files, printer) of one by another using TCP/IP pr
2.4 DESIGN TECHNIQUES/APPROACH OF AN OPERATING SYSTEM: Monolithic Kernel, Micro Kernel, Hybrid
2.4.0 KERNEL: Intermediary layer btw hardware & app programs, it makes it possible for app software to interact with the underlying hardware usi
2.4.1 MONOLITHIC KERNEL: Work in kernel space & superv mode, contain all abstraction code of the underlying hardware to perform kernel relate
2.4.2 MICRO KERNEL: Idea is to reduce kernel to only basic process communication and IO control and system services(servers) run in user space
2.4.3 HYBRID KERNEL: Modified monolithic/microkernel architecture, has additional code to improve performance, load only core module on dem
2.5 FUNCTIONS OF THE KERNEL: Interrupt Handling, Executing Processes, Memory Management, CPU Scheduling.
2.6 FEATURES/COMPONENTS OF KERNEL: System Call, Device Management, Memory Management, User Interface.
2.6.0 SYSTEM CALL: A request by a computer application, to the operating system kernel before it could access the hardware resource
2.6.1 SYSTEM CALL: Kernel determines whether to grant access to the calling application or not
2.6.0 DEVICE DRIVER: Program with built-in functions that enable OS interact with hardware devices by providing OS with info on how to communi
2.6.2 DEVICE MANAGEMENT: Kernel manages all input and output devices attached to the system through device driver. It makes call to devices
2.6.3 MEMORY MANAGEMENT: RAM is used to store both instructions & data, kernel has full control over RAM, establishing virtual addressing to pro
2.6.4 USER INTERFACE: OS kernel determine how user interact with computer, common forms are command line interface & graphical user interfa
2.7 OTHER CATEGORIES OF SYSTEM SOFTWARE: Device Drivers, Firmware, Utilities, Translators.
2.7.1 DEVICE DRIVERS: Are built-in programs that enable certain piece of hardware device to be recognized by the OS or transparently make call t
2.7.2 FIRMWARE: Embedded programs in devices to enable device control and identification
2.7.3 UTILITIES: Software that sit btw OS & app software, intended for diagnostic & maintenance task, enhance optimal functionality of app & dev
2.7.4 TRANSLATOR: Translates high-level languages to low-level machine codes. Examples include compiler, interpreter, and assembler

CHAPTER THREE (3)


3.1 INSTRUCTION: Set of bits for control unit to interpret, instructing computer to perform specific operation, stored in memory like data
3.2 INSTRUCTION CYCLE: Fetch-Decode-Execute cycle, process by which a program fetch instruction from memory, determine what to do & A
3.2.1 REGISTERS/CIRCUIT INVOLVED IN INSTRUCTION CYCLE: Program Counter, Memory Address Register, Memory Buffer Register, Control Unit
3.2.1.1 PROGRAM COUNTER (PC): An incrementing counter that keep track of the memory address of which instruction is to be executed next
3.2.1.2 MEMORY ADDRESS REGISTER (MAR): The address in the main memory that is currently been read or written
3.2.2.3 MEMORY BUFFER REGISTER (MBR): A two-way register that hold data fetched from or data stored in memory while awaiting CPU to proce
3.2.1.4 CURRENT INSTRUCTION REGISTER (CIR): A temporary holding ground for the instruction that has just been fetched from memory
3.2.1.5 CONTROL UNIT (CU): Decodes instruction in CIR, then select and coordinate machine resource i.e data source register & a particular oper
3.2.1.6 ARITHMETIC LOGIC UNIT (ALU): Performs arithmetic and logical operations
3.3 PARTS OF AN INSTRUCTION: Opcode (Mnemonic), Operands, Address
3.3.0 MNEMONICS: Used to specify Opcode that represent an operational machine language instruction, provides user quick access to functions
3.3.1 OPCODE: Portion of a machine language instruction that specifies what operation is to be performed by the CPU (Microprocessor Instructio
3.3.2 OPERANDS: Entities operated upon by the instruction (mnemonics), operands may be a processor register or memory address or literal etc
3.3.2.1 TYPES OF OPERAND: Register, Immediate, Direct, Indirect, Implied.
3.3.3 ADDRESSES: Location in the memory for the specified data
3.4 ADDRESSING MODES: Refers to the way in which the operand of an instruction is specified or how operands are referenced
3.4.1 REGISTER ADDRESSING: Processing of data is btw registers does not involve memory, the register may be the 1st or 2nd operand or both
3.4.2 IMMEDIATE ADDRESSING: Has constant value, 1st operand may be a register or memory while second is immediate. 1st defines length of 2nd
3.4.3 DIRECT MEMORY ADDRESSING: One operand refer to a memory, second reference a register, a scheme in which it address specify the oper
3.4.4 INDIRECT MEMORY ADDRESSING: Effective address of d operand is d content of a register or memory loca whose address appears in the in
3.4.5 INDEX ADDRESSING: The addition of base address and displacement index value gives actual physical address of operand in memory
3.4.6 ADVANTAGES OF ADDRESSING MODES: Help reduce number of bits in the addressing field of the instruction
3.5 REGISTER: Fast memory or variable built-in a processor, it holds instructions, storage address, bit sequence, it allow arithmetic & logical
3.5.1 REGISTER CONTROL MECHANISM: Hardwired, Microprogrammed
3.5.1.1 HARDWIRED: Control logic is implemented with gates, flip flops, decoders and other digital circuits
3.5.1.2 MICROPROGRAMMED: Control information is stored in a control program which is programmed to perform steps to implement instruction
3.5.2 TYPES OF REGISTER: General Purpose Registers, Control Registers, Segment Registers
3.5.2.1 GENERAL PURPOSE REGISTER: Data Registers, Pointer Registers, Index Registers (They are used to store/hold data or memory location ad
3.5.2.1 DATA REGISTER: Basically a storage space for unit of memory
3.5.2.1 POINTER REGISTER: Interpreted as memory address by an instruction meaning, fetch a data located at that memory address
3.5.2.1 INDEX REGISTER: Modify operand addresses during the run of a program
3.5.2.2 CONTROL FLAG REGISTERS: Called status register, their purpose is to indicate the current state of a processor by setting individual bit cal
3.5.2.3 SEGMENT REGISTERS: It stores starting address of a data, to reference MEM locati, uses of offset value to get location of data/instruction
3.6 PROGRAM COUNTER: Hold address of the next instruction to be executed, as it is fetched, the counter increases it stored value by 1
3.7 MICROPROCESSOR INSTRUCTIONS AND MEANING: CMP, JMP, ADD, SUB, MUL, DIV, MOV
3.7.1 CMP: Subtract one operand from the other for comparing whether the operands are equal or not, set flag as true if equal
3.7.2 JUM: Transfer program control or flow by changing the instruction pointer register at memory location indicated by the operand which spe
3.7.3 ADD: Add two numbers together, the operation will modify carry and zero flag
3.7.3 SUB: Subtract one number from another, the operation will modify carry and zero flag
3.7.4 MUL AND DIV: Multiplies or divides the A register with the given value. This operations will modify the carry and zero flag.
3.7.5 MOV: Copies a value from src to dest. The MOV instruction is the only one able to directly modify the memory
3.7.6 ASSEMBLER CODE/COMMANDS: HLT, JNZ, INX, DCR, STAX, MVI, LXI

CHAPTER FOUR (4)


4.1 COMPILER: A translator that transform source code written in high level to low level language
4.1.1 FRONT END: It’s d 1st pass & referred as analytic part, it is platform independent, it output is a 3AC & encompass lexical, syntax, semantic
4.1.2 BACK END: It’s d 2nd pass &referred as synthetic part, it is platform dependent, convert intermediate code to executable code, it encompas
4.2 STAGES OF COMPILATION PROCESSES: Lexical Analyzer, Syntax Analyzer, Semantic Analyzer, Code Optimizer, Intermediate Code Generato
4.2.1 LEXICAL ANALYSIS: work as a text scanner, it scan the source code as a stream of character & separate them into lexical units (tokens
4.2.2 SYNTAX ANALYSIS: The token is taken as input, it arrangement is checked to ensure it syntactically correct, to generate parse/syntax
4.2.3 SEMANTIC ANALYSIS: Symbol table is created here, check whether parse tree follow semantic rules, check type mismatch, incompati
4.2.4 INTERMEDIATE CODE GENERATION: It’s d 3AC, resemble assembly language, it’s been referred as code btw source & target code,
make
4.2.5 CODE OPTIMIZATION: Remove redundant code for efficient memory management & improve execution speed, goal is to make it faster
4.2.6 TARGET CODE GENERATION: Optimized code is mapped/translated to target/reloadable/executable code, assignment of register, mem
4.2.7 SUMMARY: The output of one stage is taken as input of another stage, six stages in total. Two passes in total, 1 st pass (front) & 2nd pass (bac
4.3 TOKEN: Symbolic names of the entities that make up the text of a program, a sequence of character that can be identified as a single entit
4.3.1 WHAT ARE THE TYPES OF TOKENS: Keywords (int), Identifiers (total), Constant (50), Stings (“hello”), Symbols (%), Operators (+)
4.3.2 TOKENIZATION: The act of breaking up a sequence of tokens (strings, phrases, keywords) into pieces, in lexical analysis
4.4 LEXEMES: Sequence of character in source program that matches the pattern of a token, identified as an instance of a token, they are build
4.5 COMPARE AND CONTRAST: Lexemes help break down source code into token while token are the character that makes up a source code
4.6 COMPILER ERROR HANDLING ROUTINE: Lexical Analyzer (wrong spelled token), Syntax Analyzer (missing parenthesis), Symbol Table (Error
4.7 TYPES OF COMPILERS: One Pass Compiler, Decompiler, Cross Compiler, Narative Code Compiler, Source Compiler
4.7.1 THE NEED FOR COMPILER: It execute faster because executable files is optimized, U can execute program other than the machine where it
4.7.2 APPLICATION OF COMPILERS: Support optimization for computer architecture parallelism
4.7.3 ATTRIBUTES OF A COMPILER: Translate High-level Language to it equivalent machine code, Detect errors.
4.8 INTERPRETER: Program that translate source code in high level language to executable machine code on a line by line basis (immediately)
4.8.1 DIFFERENCE BETWEEN COMPILER AND INTERPRETER: Interpreter translate immediately on line by line basis while compiler translate begin
4.8.2 SOURCE LANGUAGE: Programmer input source code with this language, it is understandable by human, language that need to be translated
4.8.3 TARGET LANGUAGE: Instruction are received & executed as object code, this is the language computer understand to carry out our instruct

CHAPTER FIVE (5)


5.1 ASSEMBLER: Translate assembly language to machine language, translate a low-level language to a much lower-level language.
5.1.1 ASSEMBLY LANGUAGE (ASM): It implements a symbolic representation of the machine code needed to program a given CPU architecture
5.1.2 ADVANTAGES OF ASSEMBLY LANGUAGE: Symbolic programming is easier to understand, thus time-saving for the programmer
5.1.3 DISADVANTAGES OF ASSEMBLY LANGUAGE: It is machine dependent, cannot be used in other architecture
5.1.4 SIGNIFICANCE OF ASSEMBLY LANGUAGE: Writing device driver, Suitable for writing interrupt service routine
5.1.5 ASSEMBLY INSTRUCTIONS AND INTERPRETATIONS: MOV, ADD, INC
5.1.5.1 MOV: MOV is an X86 assembly language instruction, it is meant to move data between registers and memory
5.1.5.2 ADD: Adds together its two operands, storing the result in its 1st operand, both operands may be registers or 1 operand is memory location
5.1.5.3 INC: INC instruction is used for incrementing an operand by one. It works on a single operand that can be either in a register or in memory
5.1.6 TYPES OF ASSEMBLER: One Pass assembler, Two Pass Assembler, Resident Assembler, Cross Assembler
5.1.6.1 ONE PASS ASSEMBLER: Perform single scan over the source code. If it encounters any undefined label, it puts it into symbol table along
5.1.6.2 TWO PASS ASSEMBLER: Two pass assembler performs two sequential scans over the source code. It divides the procedure into two steps
5.1.6.3 MULTI-PASS ASSEMBLER: more than one pass is used. It creates a number of passes that is necessary to process the definition of symbols.
5.1.6.4 RESIDENT ASSEMBLER: If an assembler which runs on a computer and produces the machine codes for the same computer
5.1.6.5 CROSS ASSEMBLER: A cross assembler is a program which generates machine code for a processor other than the one it is currently run on
5.1.6.6 TASM: Turbo Assembler developed by Borland which runs on and produces code for 16- or 32-bit x86 DOS or Microsoft Windows. It can be
5.1.6.7 ASSEMBLY ERRORS: Symbol Table Overflow, Parenthesis/Bracket Mismatch, Bad Index Register, Illegal Constant
5.1.7 ASSEMBLY LANGUAGE OPCODES: AAC, AAD, AAO, AAR
5.1.8 MACHINE LANGUAGE: A set of instruction consisting of binary (OS and 1s), executed directly by the central processing unit (CPU)
5.2 ASSEMBLY PROGRAMS: Add two numbers, Print hello world, Sum of even numbers in a given series
5.2.1 ASSEMBLY PROGRAM TO ADD TWO NUMBERSDATA SEGMENT: Assembly program that add two numbers
5.2.2 ASSEMBLY PROGRAM TO PRINT HELLO WORLD: Assembly program that print “hello world”
5.2.3 ASSEMBLY PROGRAM TO FIND SUM OF EVEN NUMBERS IN A GIVEN SERIES: Assembly program to compute the sum of even no in a series
5.2.4 DECLARATION OF INTEGER IN ASSEMBLY LANGUAGE: DB, DW, DD, DQ, DT
5.3 EXTENDING SIGNED AND UNSIGNED INTEGERS: Moving data btw register of different size is illegal, so we must sign extend integer to conv
5.3.1 BYTE: Tells d assembler to reserve a block of storage & remember it length in byte, length is determined by number of byte in d initializer
5.3.2 WORD: Number of bits that can be transferred at one time on the data bus and stored in a register
5.3.3 QUAD WORD: A define directive in assembly for reserving space, it Allocates 8-byte integers used with 8087-family coprocessor instruction

CHAPTER SIX (6)


6.1 INTERRUPT: A signal to the processor to get the attention of the CPU indicating an event need immediate attention
6.1.1 WHAT HAPPENS WHEN AN INTERRUPT IS CALLED: CPU stop executing it current program, control is then passed to interrupt service rout
6.1.2 HOW INTERRUPT IS SERVICED: Processor register save the status of the program currently executing on the stack, it then branches to ISR
6.1.3 TYPES OF INTERRUPTS: Hardware Interrupt, Software Interrupt, Processor Interrupt
6.1.3.1 HARDWARE INTERRUPT: Used by devices to communicate the OS that they require attention, asynchronous & can occur in the middle of i
6.1.3.2 SOFTWARE INTERRUPT: Called trap, occur when application program stop responding or terminate if request certain service from the OS
6.1.3.3 PROCESSOR INTERRUPT (EXEPTION): Caused by exceptional condition in the instruction set of the processor itself
6.2 SYSTEM BUS: Provide communication path for data and control signal moving between the major components of the computer system
6.2.1 HOW DOES A SYSTEM BUS WORK: Data, Address, Control Bus (Each of the three bus has it separate characteristics and responsibilities)
6.2.2 ARRANGEMENT OF BUS IN A COMPUTER SYSTEM: A diagram depicting how these bus system are organized
6.2.3 TYPES OF SYSTEM BUS: Address Bus, Data Bus, Contol Bus.
6.2.3.1 ADDRESS BUS: Used to specify memory location for the data being transferred
6.2.3.2 DATA BUS: Bi-directional path, carries the actual data between the processor, the memory and the peripherals
6.2.3.3 CONTROL BUS: Carries the control, timing and coordination signals to manage various functions across the system
6.3 SYMBOL TABLE: A data structure created by a translator in order to store information about the occurrence of various entities
6.4 SPOOLING: Means Simultaneous Peripheral Operation Online, it put data into a temporary working area so it can be accessed by another
6.4.1 ADVANTAGES OF SPOOLING: Capable of overlapping I/O operation for one job with processor operations for another job
6.4.2 DISADVANTAGES OF SPOOLING: It is difficult to debug
6.5 BUFFER: Buffer is a region of physical memory storage used to temporarily store data while it is been moved from one place to another
6.5.1 BUFFERING: Preloading data into reserved area of memory (buffer)
6.5.2 ADVANTAGES OF BUFFERING: Used to improve computer performance, allow efficient access to data on disk
6.5.3 DISADVANTAGES OF BUFFERING: It is costly, has fixed size
6.6 DIFFERENCE BETWEEN SPOOLING AND BUFFERING: Spooling consider disk as a huge spool or buffer while buffer is imited to memory
6.7 CACHE: A memory bank that bridges main memory and the processor, cache allow data to be read at high speed
6.7.1 CACHE VS BUFFER: cache is static RAM while buffer is dynamic RAM
CHAPTER ONE (1)
1.1 SOFTWARE
A working software that serve specific objective (use) is termed as a system, the two words
are commonly used interchangeably. Software is a set of instructions or programs that run on
a computer and used to operate computers and execute specific tasks. In order words it tell
a computer what to do or how to perform a task

TYPES OF SOFTWARE
1.1.1 APPLICATION SOFTWARE
Application Software Is a computer software package that performs a specific function
directly for an end user. In simple terms is a program designed for end users

TYPES
 MS Word, WordPad and Notepad (Word Processor)
 Internet browsers like Firefox, Safari, and Chrome (Internet/Web Browsers)
 Auto CAD
 MySQL, Oracle, MS Access (Database Application)
 Real Player, Media Player (Movie Player)
 Dictionaries: Encarta, Britannica Mathematical: MATLAB Others
 Microsoft Excel (Spread Sheet)
 Adobe PageMaker (Desktop Publishing)
 Need For Speed (Games)
 Adobe Photoshop (Photo Editor)
 PowerPoint (Presentation)
 Corel Draw (Graphics)
 Outlook, Thunderbird (Email)
 Itunes, WinAmp (Audio/Music App)
 AVG, McAfee, Norton (Antivirus)

1.1.2 SYSTEM SOFTWARE


System software coordinates the activities and functions of hardware and software, in
order words it ensure communication between other software and hardware to allow
harmonious coexistence with the user.

TYPES
SYSTEMS SOFTWARE CAN BE CATEGORIZED UNDER THE FOLLOWING:
 Operating system: Harnesses communication between hardware, system programs, and
other applications.
 Device driver: Enables device communication with the OS and other programs.
 Firmware: Enables device control and identification.
 Translator: Translates high-level languages to low-level machine codes.
 Utility: Ensures optimum functionality of devices and applications.

1.3 PROGRAMMING
The process of developing and implementing various sets of instructions to enable
a computer to do a certain task. The process of designing and building an executable
computer program to accomplish a specific result. Programming is the process of
creating a set of instructions that tell a computer how to perform a
task. Programming can be done using a variety of computer "languages," such as SQL,
Java, Python, and C++. Programming Is the activity of coding, using a programming
language to get a computer to behave how you want it to. Every line of code tells
the computer to do something. Each line of code is called script and it’s
designed to carry out a job.
1.3.1 SYSTEM PROGRAMMING AND APPLICATION PROGRAMMING
System programming is the activity of programming operating system software. While
application programming is the activity of programming application software that is used
directly by the user. Systems programming aims to develop software and software
platforms which provide services to other software. While Application programming is
used to build application software meant for end user. application programming aims to
produce software which provides services to the user directly

1.4 COMPILE TIME


In simple terms, compile-time is the instance where the code you entered is converted to
executable. Compile-time checking occurs during the compile time. Compile time errors are
error occurred due to typing mistake, if we do not follow the proper syntax and semantics of
any programming language then compile time errors are thrown by the compiler. They wont
let your program to execute a single line until you remove all the syntax errors or until you
debug the compile time errors. The following are usual compile time errors:

 Syntax errors
 Typechecking errors
 Compiler crashes (Rarely)

1.5 RUN TIME


In simple terms, run-time is the instance where the executable is running. Run-time type
checking happens during run time of programs. Runtime errors are the errors that are
generated when the program is in running state. These types of errors will cause your
program to behave unexpectedly or may even kill your program. They are often referred
as Exceptions. The following are some usual runtime errors:
 Division by zero
 Dereferencing a null pointer
 Running out of memory

2.1 OPERATING SYSTEM


Operating system is a system resource manager that control all the activities and resources of
a computer system. Operating systems coordinates all other software running on a computer
system and ensure their smooth operation
Operating system is a system program or software that act as an interface between the user
and the hardware.

2.1.1 CONCEPTUAL VIEW OF AN OPERATING SYSTEM


2.2 TYPES OF OPERATING SYSTEM
2.2.1 BATCH OPERATING SYSTEM
Batch operating system is an operating system in which similar task are collected in batches
for processing and the system performs the operation in the order of submission that is first
come first serve (FCFS).

ADVANTAGES OF BATCH PROCESSING


 Batch processing takes much of the work of the operator to the computer.
 Increased performance as a new job get started as soon as the previous job is
finished, without any manual intervention.

SUMMARY
 It is very difficult to guess or know the time required by any job to complete. Processors
of the batch systems know how long the job would be when it is in queue
 Multiple users can share the batch systems
 The idle time for batch system is very less
 It is easy to manage large work repeatedly in batch systems

DISADVANTAGES OF BATCH PROCESSING


 Difficult to debug program.
 A job could enter an infinite loop.
 Due to lack of protection scheme, one batch job can affect pending jobs

SUMMARY
 The computer operators should be well known with batch systems
 Batch systems are hard to debug
 It is sometime costly
 The other jobs will have to wait for an unknown time if any job fails

Examples of Batch based Operating System: Payroll System, Bank Statements etc.

2.2.2 TIME SHARING OPERATING SYSTEM


Time sharing or multitasking is a logical extension of multiprogramming, it is an operating
system that allows two or more programs in memory to be executed simultaneously by
switching between these programs very fast in order of milliseconds, thereby creating an
illusion that all programs are running at the same time.
ADVANTAGES OF TIME-SHARING OS:
 Each task gets an equal opportunity
 Less chances of duplication of software
 CPU idle time can be reduced

SUMMARY
High CPU efficiency

DISADVANTAGES OF TIME-SHARING OS
 Reliability problem
 One must have to take care of security and integrity of user programs and data
 Data communication problem

SUMMARY
Complex operating system is required

EXAMPLES
Examples of Time-Sharing OSs are: Multics, Unix etc.

2.2.3 DISTRIBUTED OPERATING SYSTEM


Distributed operating system is an operating system that consist of a number of a number of
computers that are connected and managed such that job processing load are shared among
the constituent computers.
ADVANTAGES OF DISTRIBUTED OPERATING SYSTEM
 Failure of one will not affect the other network communication, as all systems are
independent from each other
 Electronic mail increases the data exchange speed
 Since resources are being shared, computation is highly fast and durable
 Load on host computer reduces
 These systems are easily scalable as many systems can be easily added to the network
 Delay in data processing reduces

SUMMARY
Shorter response time and higher throughput

DISADVANTAGES OF DISTRIBUTED OPERATING SYSTEM


 Failure of the main network will stop the entire communication
 To establish distributed systems the language which are used are not well defined yet
 These types of systems are not readily available as they are very expensive. Not only
that the underlying software is highly complex and not understood well yet

DISADVANTAGES
Difficult to implement

Examples of Distributed Operating System are- LINUS etc.

2.2.4 NETWORK OPERATING SYSTEM


Network operating system is an operating system run on a server, it provides the server
capabilities to manage data, user, access, and other networking functions.

ADVANTAGES OF NETWORK OPERATING SYSTEM


 Highly stable centralized servers
 Security concerns are handled through servers
 New technologies and hardware up-gradation are easily integrated to the system
 Server access are possible remotely from different locations and types of systems

SUMMARY
New technology is easily integrated into the system

DISADVANTAGES OF NETWORK OPERATING SYSTEM


 Servers are costly
 User has to depend on central location for most operations
 Maintenance and updates are required regularly
SUMMARY
Cost and level of expertise required

Examples of Network Operating System are: Microsoft Windows Server 2003, Microsoft
Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD etc.

2.2.5 REAL TIME OPERATING SYSTEM


A real time operating system is an operating system that must process inputs immediately and
respond to them very quickly, it cannot afford to be late with a response to an event. Real-
time systems are used when there are time requirements are very strict like missile systems,
air traffic control systems, robots etc.

TWO TYPES OF REAL-TIME OPERATING SYSTEM WHICH ARE AS FOLLOWS:


 HardReal-TimeSystems:
These OSs are meant for the applications where time constraints are very strict and
even the shortest possible delay is not acceptable. These systems are built for saving
life like automatic parachutes or air bags which are required to be readily available in
case of any accident. Virtual memory is almost never found in these systems.
 SoftReal-TimeSystems:
These OSs are for applications where for time-constraint is less strict.

ADVANTAGES OF RTOS
 Maximum Consumption: Maximum utilization of devices and system,thus more output
from all the resources
 Task Shifting: Time assigned for shifting tasks in these systems are very less. For
example in older systems it takes about 10 micro seconds in shifting one task to another
and in latest systems it takes 3 micro seconds.
 Focus on Application: Focus on running applications and less importance to applications
which are in queue.
 Real time operating system in embedded system: Since size of programs are small,
RTOS can also be used in embedded systems like in transport and others.
 Error Free: These types of systems are error free.
 Memory Allocation: Memory allocation is best managed in these type of systems.
SUMMARY
Real time operating system is valued for how quickly or predictably it responds

DISADVANTAGES OF RTOS
 Limited Tasks: Very few tasks run at the same time and their concentration is very less
on few applications to avoid errors.
 Use heavy system resources: Sometimes the system resources are not so good and they
are expensive as well.
 Complex Algorithms: The algorithms are very complex and difficult for the designer to
write on.
 Device driver and interrupt signals: It needs specific device drivers and interrupt
signals to response earliest to interrupts.
 Thread Priority: It is not good to set thread priority as these systems are very less prone
to switching tasks.

SUMMARY
The amount of work it can perform in a given period of time is lower.

EXAMPLES
Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging
systems, industrial control systems, weapon systems, robots, air traffic control systems, etc

2.2.6 MULTIPROGRAMMING OPERATING SYSTEM


Multiprogramming is an operating system that allows two or more programs, tasks, threads,
processes to reside in main memory, sharing the same processor and executing these process
one at a time. Multiprogramming assumes a single shared processor. Multiprogramming
increases CPU utilization by organizing jobs so that the CPU always has one to execute.

ADVANTAGES OF MULTIPROGRAMMING
 High and efficient CPU utilization.
 User feels that many programs are allotted CPU almost simultaneously.

SUMMARY
 High CPU utilization
 better performance-shorter response time & higher throughput 2. Better Reliability-if
one processor brekdown then other takes its workload
 increases CPU utilization. ii) It decreases total read time needed to execute a job.

DISADVANTAGES OF MULTIPROGRAMMING
 CPU scheduling is required.
 To accommodate many jobs in memory, memory management is required.

SUMMARY
CPU scheduling and Memory management is required

2.2.7 MULTIPROCESSING OPERATING SYSTEM


Multiprocessing operating system is an operating system configured to have more than one
independent processing unit (multiple processors) that allows two or more programs to be
executed at the same time.

ADVANTAGES
Allows operating system to handle large, complex procedures or operation quickly
DISADVANTAGES
Work speed is affected if one constituent processor fails

DIFFERENTIATE BETWEEN MULTIPROGRAMMING AND MULTIPROCESSING OPERATING


SYSTEM
Multiprogramming operating sytem Multiprocessing operating system
Multiple processes are executed one at a time Multiple processes are executed at the same
time
Has one processing unit (processor) Has more than one processing unit

2.2.8 MULTITASKING
Multitasking is when multiple jobs are executed by the CPU simultaneously by switching
between them. Switches occur so frequently that the users may interact with each program
while it is running. An OS does the following activities related to multitasking –

2.3 FUNCTION OF AN OPERATING SYSTEM


SERVICES RENDERED BY AN OPERATIONG SYSTEM
2.3.1 PROCESS MANAGEMENT
The central processing unit is responsible for running or executing programs, the kernel takes
responsibility for deciding at any time which of many running programs should be allocated to
the processor.

2.3.2 MEMORY MANAGEMENT


The primary role of the memory management system is to satisfy requests for memory
allocation. Sometimes this is implicit, as when a new process is created. At other
times,processes explicitly request memory. Either way, the system must locate enough
unallo-cated memory and assign it to the process

2.3.3 FILE MANAGEMENT


File is a sequence of bit, byte, lines or records whose meaning is defined by its creator and
user, an operating system file manager is responsible for creating, deleting and manipulating,
backup and mapping file or directories onto disk.

Every computer file is stored in a linear space on a storage device of finite capacity and each
file has its address on storage. A file system keeps tracks of unused space on disk as well as
additional information about each file such as name, size, date, encryption etc.
2.3.4 SECONDARY STORAGE MANAGEMENT
Operating system controls all storage operations, how data or files will be stored into the
computers and how files will be accessed by the user. It also allows reading, writing of data,
file or directories where content can be copied from one place to another.

2.3.5 INPUT/OUTPUT MANAGEMENT


Input devices like mouse, keyboard, scanner etc and output devices like monitor, printer etc
are input/output devices. Operating system has the capability to hide peculiarities of specific
hardware devices from the user, the peculiarities of I/O devices are hidden from the bulk of
the operating it’s self by I/O device

2.3.6 COMMAND INTERPRETER


Command interpreter is part of an operating system called shell, it understands and executes
commands given by users as control statements that are entered interactively by human from
a program

2.3.7 NETWORKING
Operating system are capable of using TCP/IP networking protocols, this feature allows
networking of computers where one system to appear on the network of another system,
there by sharing the resources of one another such as files, printers, scanners, etc.

2.4 DESIGN TECHNIQUES/APPROACH OF AN OPERATING SYSTEM


KERNEL
Kernel is an operating system program that serves as an intermediary layer between hardware
and application programs. A kernel makes it possible for application software to interact with
the underlying hardware of the operating system, application software achieves this by
issuing service requests to the kernel and this request is called “system calls”. When a service
request is received and granted the kernel translates it into data processing instructions for
CPU or other device component to execute. Kernel is the core of an operating system

2.4.1 MONOLITHIC KERNELS


Monolithic kernel is a system program that contains all the code or abstractions of the
underlying hardware; it contains all the core operating system functions and device drivers
required for performing kernel related task. In monolithic the entire operating system is
working in kernel space and his alone in supervisor mode.

2.4.2 MICRO KERNELS


Provides a small set of simple hardware abstractions and use applications called servers to
provide more functionality. The idea behind microkernel is to reduce kernel to only basic
process communication and IO control and system services (servers) run in user space just like
any normal process

2.4.2 HYBRID
Hybrid are modified micro kernels, except that they include additional code in kernel space
to increase performance, in order words hybrid approach is derived from best of micro and
monolithic kernel architecture, instead of loading the entire code(core module) on memory
at once , it dynamically load core module on memory on demand.

2.5 FUNCTIONS OF THE KERNEL


(1) Interrupt handling
(2) Executing processes
(3) Memory management
(4) CPU scheduling
2.6 FEATURES/COMPONENTS OF KERNEL
2.6.1 SYSTEM CALLS
System calls can simply be defined as a request by a computer application program to the
operating system kernel before it could access the hardware resources. The kernel
determines whether the calling application should be granted the requested service or not, if
granted kernel executes instructions which cause a switch into user mode and returns control
back to the calling program.

A system call is a mechanism that is used by application programs to request service of the
operating system’s kernel, they use machine-code instructions which cause the processor to
change mode (supervisor/protected mode), this mode is where operating system performs
actions like accessing hardware devices or memory management unit.

2.6.2 DEVICE MANAGEMENT


Kernel manages all input devices such as mouse, keyboard etc and output device scanner,
printer etc attached to the system through device driver, device driver is a computer program
that enables operating system to interact with hardware device by providing the operating
system with information on how to control and communicate with certain piece of hardware.
Device drivers is a computer program with built-in functions that provides an interface
through which the operating system can recognize or transparently make calls to the device
such as disk drives, keyboard, sound cards etc.

2.6.3 MEMORY MANAGEMENT


Random access memory RAM is used to store both program instruction and data kernel has full
access to this memory and must allow processes to access this memory by virtual addressing
achieved by paging and/or segmentation, virtual addressing allows kernel to make a given a
given physical address appear to be another address.

2.6.4 USER INTERFACE


An operating system user interface determines how users interact with the computer. The
two most common forms of user interface are Command Line Interface (CLI) and the graphical
user interface (GUI). Command Line Interface (CLI) provide a prompt at which commands
implemented with a program called command line shell can be given line by line, examples of
CLI are UNIX shell and windows command prompt. But in contrast graphical user interface
(GUI) provides a visual environment where a device such as mouse is used to navigate the
system and perform tasks. GUI is implemented in Microsoft windows, Apple’s Mac OS X
etc.

2.7 OTHER CATEGORIES OF SYSTEM SOFTWARE


2.7.1 DEVICE DRIVERS
Driver software is a type of system software which brings computer devices and peripherals to
life. Drivers make it possible for all connected components and external add-ons perform
their intended tasks and as directed by the OS. Without drivers, the OS would not assign any
duties. Examples of devices which require drivers:

 Mouse
 Keyboard
 Soundcard
 Display card
 Network card
 Printer
If a device is newer than the operating system, the user may have to download drivers from
manufacturer websites or alternative sources.

2.7.2 FIRMWARE
Firmware is the operational software embedded within a flash, ROM, or EPROM memory chip
for the OS to identify it. It directly manages and controls all activities of any single hardware.

Traditionally, firmware used to mean fixed software as denoted by the word firm. It was
installed on non-volatile chips and could be upgraded only by swapping them with new,
preprogrammed chips.

This was done to differentiate them from high-level software, which could be updated
without having to swap components. Today, firmware is stored in flash chips, which can be
upgraded without swapping semiconductor chips.

2.7.3 UTILITIES
Utilities are types of system software which sits between system and application software.
These are programs intended for diagnostic and maintenance tasks for the computer. They
come in handy to ensure the computer functions optimally. Their tasks vary from crucial data
security to disk drive defragmentation.

Utility software helps to manage, maintain and control computer resources. Most are third-
party tools but they may come bundled with the operating system. Examples of utility
programs include: Disk defragmenters, System Profilers, Network Managers, Application
Launchers, Antivirus software, Backup software, Disk repair, Disk Cleaners, Registry Cleaners,
Disk Space analyzer, file manager, File Compression, Data Security and many more.

EXAMPLES AND FEATURES OF UTILITY SOFTWARE INCLUDE:


 Antivirus and security software for the security of files and applications, e.g.,
Malwarebytes, Microsoft Security Essentials, and AVG.
 Disk partition services such as Windows Disk Management, Easeus Partition Master, and
Partition Magic.
 Disk defragmentation to organize scattered files on the drive. Examples include Disk
Defragmenter, Perfect Disk, Disk Keeper, Comodo Free Firewall, and Little Snitch.
 File Compression to optimize disk space such as WinRAR, Winzip, and 7-Zip.
 Data backup for security reasons, e.g., Cobian, Clonezilla, and Comodo.
 Hardware diagnostic services like Hard Disk Sentinel, Memtest, and Performance Monitor.
 Data recovery to help get back lost data. Examples include iCare Data Recovery, Recuva,
and EaseUs Data Recovery Wizard.
 Firewall for protection against external threats, e.g., Windows Firewall.

2.7.4 TRANSLATOR
A translator is a programming language processor that converts a computer program from one
language to another. It takes a program written in source code and converts it into machine
code. It discovers and identifies the error during translation.

It translates high-level language program into a machine language program that the central
processing unit (CPU) can understand. It also detects errors in the program.
DIFFERENT TYPES OF TRANSLATORS
THERE ARE 3 DIFFERENT TYPES OF TRANSLATORS AS FOLLOWS
2.7.4.1 COMPILER
A compiler is a translator used to convert high-level programming language to low-level
programming language. It converts the whole program in one session and reports errors
detected after the conversion. Compiler takes time to do its work as it translates high-level
code to lower-level code all at once and then saves it to memory.

A compiler is processor-dependent and platform-dependent. But it has been addressed by a


special compiler, a cross-compiler and a source-to-source compiler. Before choosing a
compiler, user has to identify first the Instruction Set Architecture (ISA), the operating system
(OS) and the programming language that will be used to ensure that it will be compatible.

2.7.4.2 INTERPRETER
Just like a compiler, is a translator used to convert high-level programming language to low-
level programming language. It converts the program one at a time and reports errors
detected at once, while doing the conversion. With this, it is easier to detect errors than in a
compiler. An interpreter is faster than a compiler as it immediately executes the code upon
reading the code. It is often used as a debugging tool for software development as it can
execute a single line of code at a time. An interpreter is also more portable than a compiler
as it is not processor-dependent, you can work between hardware architectures.

2.7.4.3 ASSEMBLER
An assembler is is a translator used to translate assembly language to machine language. It is
like a compiler for the assembly language but interactive like an interpreter. Assembly
language is difficult to understand as it is a low-level programming language. An assembler
translates a low-level language, an assembly language to an even lower-level language, which
is the machine code. The machine code can be directly understood by the CPU.

2.7.4.4 EXAMPLES OF TRANSLATORS


HERE ARE SOME EXAMPLES OF TRANSLATORS PER TYPE:
TRANSLATOR EXAMPLES
COMPILER Microsoft Visual Studio
GNU Compiler Collection (GCC)
Common Business Oriented Language (COBOL)

INTERPRETER List Processing (LISP)


Python

ASSEMBLER Fortran Assembly Program (FAP)


Macro Assembly Program (MAP)
Symbolic Optimal Assembly Program (SOAP)

2.7.4.5 ADVANTAGES AND DISADVANTAGES OF TRANSLATORS


2.7.4.5.1 ADVANTAGES OF THE COMPILER
 The whole program is validated so there are no system errors.
 The executable file is enhanced by the compiler, so it runs faster.
 User do not have to run the program on the same machine it was created.

DISADVANTAGES OF THE COMPILER:


 It is slow to execute as you have to finish the whole program.
 It is not easy to debug as errors are shown at the end of the execution.
 Hardware specific, it works on specific machine language and architecture.
2.7.4.5.2 ADVANTAGES OF THE INTERPRETER
 You discover errors before you complete the program, so you learn from your
mistakes.
 Program can be run before it is completed so you get partial results immediately.
 You can work on small parts of the program and link them later into a whole program.

DISADVANTAGES OF THE INTERPRETER


 There’s a possibility of syntax errors on unverified scripts.
 Program is not enhanced and may encounter data errors.
 It may be slow because of the interpretation in every execution.

2.7.4.5.3 ADVANTAGES OF THE ASSEMBLER


 The symbolic programming is easier to understand thus time-saving for the
programmer.
 It is easier to fix errors and alter program instructions.
 Efficiency in execution just like machine level language.

DISADVANTAGES OF THE ASSEMBLER


 It is machine dependent, cannot be used in other architecture.
 A small change in design can invalidate the whole program.
 It is difficult to maintain.

3.1 INSTRUCTION
An instruction code is a group of bits that instruct the computer to perform a specific
operation, an instruction must also include one or more operands, which indicate the
registers and/or memory addresses from which data is taken or to which data is deposited.

The instructions are stored in computer memory in the same manner that data is stored. The
control unit interprets these instructions and uses the operations code to determine the
sequences of micro operations that must be performed to execute the instruction

3.2 INSTRUCTION CYCLE


The Fetch-Decode-Execute cycle of a computer is the process by which a computer

1. fetches a program instruction from its memory,


2. determines what the instruction wants to do,
3. and carries out those actions.
3.2.1 REGISTERS/CIRCUIT INVOLVED IN INSTRUCTION CYCLE
THE CIRCUITS USED IN THE CPU DURING THE CYCLE ARE:

3.2.1.1 PROGRAM COUNTER (PC)


An incrementing counter that keeps track of the memory address of which instruction is to be
executed next.

3.2.1.2 MEMORY ADDRESS REGISTER (MAR)


The address in main memory that is currently being read or written

3.2.1.3 MEMORY BUFFER REGISTER (MBR)


A two-way register that holds data fetched from memory (and ready for the CPU to process)
or data waiting to be stored in memory

3.2.1.4 CURRENT INSTRUCTION REGISTER (CIR)


A temporary holding ground for the instruction that has just been fetched from memory

3.2.1.5 CONTROL UNIT (CU)


decodes the program instruction in the CIR, selecting machine resources such as a data source
register and a particular arithmetic operation, and coordinates activation of those resources

3.2.1.6 ARITHMETIC LOGIC UNIT (ALU)


Performs mathematical and logical operations

3.3 PARTS OF AN INSTRUCTION


3.3.0 MNEMONICS
Mnemonics are used to specify an opcode that represents a complete and operational
machine language instruction. This is later translated by the assembler to generate the object
code. For example, the mnemonic MOV is used in assembly language for copying and moving
data between registers and memory locations. Assembly language uses a mnemonic to
represent each low-level machine instruction or opcode, typically also each architectural
register, flag, etc. Mnemonics are used to provide users with a means to quickly access a
function, service or process.

3.3.1 OPCODE
Operation Code is the portion of a machine language instruction that specifies what operation
is to be performed by the central processing unit (CPU). The term is an abbreviation of
operation code

The operation code of an instruction is a group of bits that define operations such as addition,
subtraction, shift, complement

Opcode is abbreviated from operation code is the portion of a machine language instruction
that specifies the operation to be performed, used to refer to a microprocessor instruction.

MOV AL, 34h


The opcode is the MOV instruction. The other parts are called the 'operands'. Operands are
manipulated by the opcode. In this example, the operands are the register named AL and the
value 34 hex.

3.3.2 OPERANDS
Operands are entities or argument operated upon by the instruction (mnemonic). The operand
may be a processor register, a memory address, a literal constant, or a label.
The operand specifies the data that needs to be acted on. The operand can also refer to a
place in memory, such as a register.

In computer programming, an operand is a term used to describe any object that is capable of
being manipulated. For example, in "1 + 2" the "1" and "2" are the operands and the plus
symbol is the operator

Operands are the objects that are manipulated and the operators are the symbols that
represent specific actions. An illustration is given below

3.3.2.1 TYPES OF OPERAND


 Register. These operands come from registers within the CPU.
 Immediate. These are plain constants that are embedded in the instruction stream.
 Direct. These are operands stored in memory. The direct address is part of the
instruction—much like an immediate—and it tells the CPU where to fetch the data
from.
 Indirect. These operands actually have two parts: The first part gives a register or
memory location that holds an address, and the second part is the actual data that’s
at the address pointed to by the first part.
 Implied. The operand isn’t explicitly stated as part of the instruction, but rather
used implicitly by the instruction. This could either be a fixed register usage (such
as using %ecx for the LOOP instruction), or a concept like “top of stack.”

3.3.3 ADDRESSES
Addresses are the locations in memory of specified data

ILLUSTRATION
ADD AX, [102]
SUMMARY
The opcode is ADD
There are two operands are AX and [102]
This instruction contains one address - 102

3.4 ADDRESSING MODES


The term addressing modes refers to the way in which the operand of an instruction is
specified or how operands are referenced. Information contained in the instruction code is
the value of the operand or the address of the result/operand

TYPES OF ADDRESS MODE


3.4.1 REGISTER ADDRESSING
In this addressing mode, a register contains the operand. Depending upon the instruction, the
Register
may be the first operand, the second operand or both. As processing data
between registers does not involve memory, it provides fastest processing of data.

EXAMPLE
MOV DX, TAX_RATE ;Registerin first operand
MOV COUNT, CX ;Registerin second operand
MOV EAX, EBX ;Both the operands are in registers
3.4.2 IMMEDIATE ADDRESSING
An immediate operand has a constant value or an expression. When an instruction with two
operands uses immediate addressing, the first operand may be a register or memory location,
and the second operand is an immediate constant. The first operand defines the length of the
data

EXAMPLE
ADD BYTE_VALUE,65; An immediate operand 65 is added
MOV AX,45H; Immediate constant 45 His transferred to AX

3.4.3 DIRECT MEMORY ADDRESSING


Direct memory addressing, one of the operands refers to a memory location and the other
operand references a register. Direct addressing is a scheme in which the address specifies
which memory word or register contains the operand.

EXAMPLE 1
1) LOAD R1, 100 Load the content of memory address 100 to register R1.
2) LOAD R1, R2 Load the content of register R2 to register R1

Direct addressing mode means that the value for a given instruction in assembly programming
is pointed to by a given value. This means the value is variable, based on what is stored in
memory at a given address.

EXAMPLE 2
ADD BYTE_VALUE, DL; Adds the register in the memory location
MOV BX, WORD_VALUE; Operand from the memory is added to register

3.4.4 INDIRECT MEMORY ADDRESSING


The effective address of the operand is the contents of a register or main memory location,
location whose address appears in the instruction. The register or memory location that
contains the address of the operand is a pointer

FOR EXAMPLE
1) LOAD R1, @100 Load the content of memory address stored at memory address100 to the
register R1.

3.4.5 INDEX ADDRESSING MODE


Index addressing mode is a category of displacement addressing mode. In index mode, the
addition of base address and displacement index value gives the actual physical address of
the operand in memory.

EXAMPLE
Add R3, (R1 + R2) Useful in array addressing: R1 - base of array R2 -
index amount

3.4.6 ADVANTAGES OF ADDRESSING MODES


1. To give programmers to facilities such as Pointers, counters for loop controls, indexing of
data and program relocation.
2. To reduce the number bits in the addressing field of the Instruction.
3.5 REGISTER
Register are fast memory or variable built in a processor, always connected to circuitry, it
that holds computer instructions/storage address/bit sequence and allows various arithmetic,
logical, control, manipulations as well as setting internal flag.

3.5.1 REGISTER CONTROL MECHANISM


The timings for all the registers are controlled a master clock generator. There are two types
of control

3.5.1.1 HARDWIRED
Hardwired – control logic is implemented with gates, flip-flops, decoders and other digital
circuits.

3.5.1.2 MICROPROGRAMMED
Microprogrammed – control information is stored in a control program, which is programmed
to perform the necessary steps to implement instructions.

3.5.2 TYPES OF REGISTER


 General registers: They are used to store/hold data or memory location address

 Control registers: Called status register, their purpose is to indicate the current state of a
processor by setting individual bit called flag

 Segment registers: Stores starting address of a data, used to reference MEM location using of
offset value to get location of data/instruction

3.5.2.1 GENERAL PURPOSE REGISTER


The general registers are referred to as accumulator and can be further divided into the
following groups –

 a) Data registers: Basically a storage space for units of memory


 b) Pointer registers: interpreted as memory address by instructions (fetch data located at
that address
 c) Index registers: modifying operand addresses during the run of a program

DATA REGISTERS
AX (AH,AL) Accumulator : Accumulator for operands and arithmetic operations
BX (BH,BL) Base : Used in referencing/addressing the location of the parameters
CX (CH,CL) Counter : for counter loop operations
DX (DH,DL) Data : used for input/output operations , division remainder

(b) POINTER REGISTERS


IP Instruction pointer : stores offset address of the next instruction to be executed
SP Stack pointer : useful for stack frames or current stack offset
BP Base pointer : for referencing values stored on stack

(c) INDEX REGISTERS


Source Index (SI) − It is used as source index for string operations
Destination Index (DI) − It is used as destination index for string operations
3.5.2.2 CONTROL REGISTERS
FLAG REGISTER
Flags are a set of variables in the CPU which determines the current state of the processor or
indicate the status of various components of the CPU. Flags are used, among others, in the
following contexts:

Flags Register (Respectively bits 11,10,9,8,7,6,4,2,0)


OF Overflow flag : Indicates a signed arithmetic overflow occurred
DF Direction flag : Controls incr. direction in string ops (0=inc, 1=dec)
IF Interrupt flag: Controls whether interrupts are enabled
TF Trap flag : Controls debug interrupt generation after instructions
SF Sign flag : Indicates a negative result or comparison
ZF Zero flag : Indicates a zero result or an equal comparison
AF Auxiliary flag: Indicates adjustment is needed after BCD arithmetic
PF Parity flag : Indicates an even number of 1 bits
CF Carry flag : Indicates an arithmetic carry occurred

3.5.2.3 SEGMENT REGISTERS


CS Code segment : stores all the instructions or codes to be executed
SS Stack segment : contain data and return addresses to
procedures/subroutines/functions
ES Extra segment : for addressing, also serve as an auxiliary data segment
DS Data segment : used to declare the memory region, where data elements are
stored for the program

3.6 PROGRAM COUNTER


A program counter is a register in a computer processor that contains the address (location)
of the instruction being executed at the current time. As each instruction gets fetched, the
program counter increases its stored value by 1. After each instruction is fetched, the
program counter points to the next instruction in the sequence. When the computer restarts
or is reset, the program counter normally reverts to 0. Program Counter (PC) is a special-
purpose register that is used by the processor to hold the address of the next instruction to be
executed. The PLA automatically updates the PC to point to the next instruction during the
op-code decode cycle. By coordinating with other hardware, in addition to the PLA, the PC is
automatically incremented as each instruction is executed. The PC can also have an address
dictated to it via the 'BRANCH' instruction.
3.7 MICROPROCESSOR INSTRUCTIONS AND MEANING
3.7.1 CMP INSTRUCTION
This instruction basically subtracts one operand from the other for comparing whether the
operands are equal or not. It does not disturb the destination or source operands. It is used
along with the conditional jump instruction for decision making. Compares two values and
sets the zero flag to true if they are equal.

ILLUSTRATION
CMP reg, reg
CMP reg, address
CMP reg, constant

3.7.2 JUMP (JMP) INSTRUCTION


J instruction transfers program control or flow of execution by changing the instruction
pointer register at memory location indicated by the operand which specifies an absolute
memory reference

3.7.3 ADD AND SUB


Adds two numbers together or subtract one number form another. This operations will modify
the carry and zero flag. SP can be used as operand with ADD and SUB.

ILLUSTRATION
ADD reg, reg
ADD reg, address
ADD reg, constant
SUB reg, reg
SUB reg, address
SUB reg, constant

3.7.4 MUL AND DIV


Multiplies or divides the A register with the given value. This operations will modify the carry
and zero flag.

3.7.5 MOV (COPY A VALUE)


Copies a value from src to dest. The MOV instruction is the only one able to directly modify
the memory. SP can be used as operand with MOV.

ILLUSTRATRATION
MOV reg, reg
MOV reg, address
MOV reg, constant
MOV address, reg
MOV address, constant
DATA MOVEMENT INSTRUCTIONS CAN BE OF THESE FORMS
SYNTAX
mov<reg>, <reg>
mov<reg>, <mem>
mov<mem>, <reg>
mov<con>, <reg>
mov<con>, <mem>

INSTRUCTIONS INTERPRETATIONS
mov %ebx, %eax — copy the value in EBX into EAX
movb $5, var(,1) — store the value 5 into the byte at location
var

OTHE COMMANDS
3.7.6 ASSEMBLER CODE/COMMANDS
1. MOV is used to transfer the data from memory to accumulator (1 Byte)
2. LXI is used to load register pair immediately using 16-bit address (3 Byte instruction)
3. MVI is used to move data immediately into any of registers (2 Byte)
4. STAX is used to store accumulator into register pair indirectly (3 Byte instruction)
5. DCR is used to decrease register by 1 (1 Byte instruction)
6. INX is used to increase register pair by 1 (1 Byte instruction)
7. JNZ is used to jump if not zero to given memory location (3 Byte instruction)
8. HLT is used to halt the program

SUMMARY
ADDRESSING MODES
Immediate value moves
mov ax, 7 ; Immediate to register
movmem, 7 ; Immediate to memory direct
movmem[bx], 7 ; Immediate to memory indirect

; Register moves
movmem, ax ; Register to memory direct
movmem[bx], ax ; Register to memory indirect
mov ax, bx ; Register to register
mov ds, ax ; General register to segment register

; Direct memory moves


mov ax, mem ; Memory direct to register
mov ds, mem ; Memory to segment register

; Indirect memory moves


mov ax, mem[bx] ; Memory indirect to register
mov ds, mem[bx] ; Memory indirect to segment register

; Segment register moves


movmem, ds ; Segment register to memory
movmem[bx], ds ; Segment register to memory indirect
mov ax, ds ; Segment register to general register
4.1 COMPILER
A compiler is a computer program that transforms source code written in a high-level
programming language into a lower level language. Basically, a compiler consists the
following stages
i) Lexical Analysis
ii) Syntax Analysis
iii) Semantic Analysis
iv) Intermediate Code Generator
v) Code Optimization
vi) Code Generation.

All these stages are in a single module

PHASES OF COMPILATION
Compilation can be broken down into two phases, which is the front end and back end, while
each phase is further divided into subdivision known as stages as analyzed below

4.1.1 FRONT END


The first Pass is referred to as the front end compiler. This pass is referred to as the analytic
part, which means all stages in the front-end analyze the high level language. The first pass is
platform independent because the output of first pass is three address code. The front end
encompass the underlisted compilation stages
(i). Lexical Analysis
(ii). Syntax Analysis
(iii). Semantic Analysis
(iv). Intermediate Code Generator

4.1.2 BACK END


The second Pass is referred to as the back end compiler. This pass is referred to as the
synthetic part, the synthesis part refers to taking input as three address code and convert
them into low level language. The second pass is platform dependent because it’s the final
phase of a compilation process, it converts the intermediate representation of program into
an executable set of instructions which is dependent on the system. The back end encompass
the underlisted compilation stages
(v) Code optimization
(vi) Code generator

SUMMARY
Front end: It maps legal code into Intermediate Representation (IR).
Back end: It maps IR onto the target machine

4.2 STAGES OF COMPILATION PROCESSES


The compilation process is a sequence of various stages. Each stage takes input from its
previous stage, has its own representation of source program, and feeds its output to the next
phase of the compiler. Let us understand the phases of a compiler
 Lexical Analysis
 Syntax Analysis
 Semantic Analysis
 Intermediate Code Generation
 Code Optimization
 Target Code Generation

4.2.1 LEXICAL ANALYSIS


This is the first stage of the compilation process and is handled by the lexical analyzer which
is also called the Scanner. In this phase the input source code is scanned and separated into
lexical units called tokens. The lexical analyses reads the input code character-by-character.

The first stage works as a text scanner. This stage scans the source code as a stream of
characters and converts it into meaningful lexemes. Lexical analyzer represents these
lexemes in the form of tokens as: <token-name, attribute-value>
This stage remove irrelevant information from the source program that syntax analyzer will
not be able to use or interpret. Irrelevant information could include things like comments and
white space etc.

THE PRIMARY FUNCTIONS OF LEXICAL ANALYZER


 Identify the lexical units in a source code
 Classify lexical units into classes like constants, reserved words, and enter them in
different tables. It will Ignore comments in the source program
 Identify token which is not a part of the language

4.2.2 SYNTAX ANALYSIS


This stage is handled by the syntax analyzer. The stream of tokens generated in the lexical
analysis stage is analyzed further to ensure that the input code follows the syntax of the
particular language. Syntax errors are detected in this stage. The output of this stage includes
abstract syntax trees

This stage is called the syntax analysis or parsing. It takes the token produced by lexical
analysis as input and generates a parse tree (or syntax tree). In this stage, token
arrangements are checked against the source code grammar, i.e. the parser checks if the
expression made by the tokens is syntactically correct. Syntax analysis is responsible for
looking at syntax rules of the language (often as a context-free grammar)

PARSER
Parser is a compiler that is used to break the data into smaller elements coming from lexical
analysis stage. A parser takes input in the form of sequence of tokens and produces output in
the form of parse tree. Parsing is of two types: top down parsing and bottom up parsing.

HERE, IS A LIST OF TASKS PERFORMED IN THIS PHASE


 Obtain tokens from the lexical analyzer
 Checks if the expression is syntactically correct or not
 Report all syntax errors
 Construct a hierarchical structure which is known as a parse tree

CONSIDER PARSE TREE FOR THE FOLLOWING EXAMPLE


(a+b)*c
4.2.3 SEMANTIC ANALYSIS
Semantic analysis is handled by the Semantic Analyzer and has to do with ensuring that the
source code follows standard semantic rules. Type Checking is taken care of in this stage. This
ensures that the variables are assigned values according to their declaration. So if a variable
have been declared as integer and then assigned a float, the error is trapped by the Semantic
Analyzer. This stage also identifies chunks of code such as operands and operators of
statements in the input code. The output of this stage includes the Parse Tree

Semantic analyzer checks whether the parse tree constructed follows the rules of language.
For example, assignment of values is between compatible data types, and adding string to an
integer. Also, the semantic analyzer keeps track of identifiers, their types and expressions;
whether identifiers are declared before use or not etc. The semantic analyzer produces an
annotated syntax tree as an output.

Semantic analyzer takes the representation made from syntax analysis and applies semantic
rules to the representation to make sure that the program meets the semantic rules
requirements of the language. In addition to performing semantic analysis at this stage of
compilation, often symbol tables are created in order to assist in code generation.

Semantic analyzer checks the semantic consistency of the code. It uses the syntax tree of the
previous stage along with the symbol table to verify that the given source code is
semantically consistent. It also checks whether the code is conveying an appropriate
meaning. Semantic Analyzer will check for Type mismatches, incompatible operands, a
function called with improper arguments, an undeclared variable, etc.

FUNCTIONS OF SEMANTIC ANALYZER


 Helps you to store type information gathered and save it in symbol table or syntax tree
 Allows you to perform type checking
 In the case of type mismatch, where there are no exact type correction rules which
satisfy the desired operation a semantic error is shown
 Collects type information and checks for type compatibility
 Checks if the source language permits the operands or not

4.2.4 INTERMEDIATE CODE GENERATION


Intermediate code refers to a code that is somehow between the source code and the target
code, an intermediate representation of the input source program. One attribute of an
Intermediate Code is ease of translation to target program. An example would be a java
programs compiled into Java Bytecodes (.class files) for the Java Virtual Machine. This
intermediate code can run on any operating system that has the JVM. One form of
intermediate code is the “Three-Address-Code” which resembles an assembly language. The
final target code is generated from the intermediate code.

After semantic analysis, the compiler generates an intermediate code of the source code for
the target machine. It represents a program for some abstract machine. It is in between the
high-level language and the machine language. This intermediate code should be generated
in such a way that it makes it easier to be translated into the target machine code.Once the
semantic analysis stage (the previous stage) is over the compiler, generates intermediate
code for the target machine. It represents a program for some abstract machine.
Intermediate code is between the high-level and machine level language. This intermediate
code needs to be generated in such a manner that makes it easy to translate it into the
target machine code.
FUNCTIONS ON INTERMEDIATE CODE GENERATION
 It should be generated from the semantic representation of the source program
 Holds the values computed during the process of translation
 Helps you to translate the intermediate code into target language
 Allows you to maintain precedence ordering of the source language
 It holds the correct number of operands of the instruction

4.2.5 CODE OPTIMIZATION


In Code Optimization, the code is optimized to remove redundant codes and the optimize for
efficient memory management as well as improve the speed of execution. The intermediate
code ensures that a target code can be generated for any machine enabling portability across
different platforms. Output of this phase is the Optimized Code

This stage does code optimization of the intermediate code. Optimization can be assumed as
something that removes unnecessary code lines, and arranges the sequence of statements in
order to speed up the program execution without wasting resources (CPU, memory). This
stage removes unnecessary code line and arranges the sequence of statements to speed up
the execution of the program without wasting resources. The main goal of this phase is to
improve on the intermediate code to generate a code that runs faster and occupies less
space.

THE PRIMARY FUNCTIONS OF THIS PHASE ARE


 It helps you to establish a trade-off between execution and compilation speed
 Improves the running time of the target program
 Generates streamlined code still in intermediate representation
 Removing unreachable code and getting rid of unused variables
 Removing statements which are not altered from the loop

4.2.6 TARGET CODE GENERATION


Here the target code is generated for the particular platform. Machine instruction is
generated from the optimized intermediate code. Assignment of variables and registers is
handled here. The output of this stage is the target code. In this stage, the code generator
takes the optimized representation of the intermediate code and maps it to the target
machine language. The code generator translates the intermediate code into a sequence of
(generally) re-locatable machine code. Sequence of instructions of machine code performs
the task as the intermediate code would do. This stage it converts the intermediate
representation of program into an executable set of instructions (often assembly).

Code generation is the last and final stage of a compiler. It gets inputs from code
optimization phases and produces the page code or object code as a result. The objective of
this phase is to allocate storage and generate relocatable machine code. The target language
is the machine code. Therefore, all the memory locations and registers are also selected and
allotted during this phase. The code generated by this phase is executed to take inputs and
generate expected outputs.

4.2.7 SUMMARY
 Compiler operates in various stages each phase transforms the source program from
one representation to another
 Six stages of compiler design are 1) Lexical analysis 2) Syntax analysis 3) Semantic
analysis 4) Intermediate code generator 5) Code optimizer 6) Code Generator
 Lexical Analysis is the first stage when compiler scans the source code
 Syntax analysis is all about discovering structure in text
 Semantic analysis checks the semantic consistency of the code
 Once the semantic analysis stage is over the compiler, generate intermediate code for
the target machine
 Code optimization stage removes unnecessary code line and arranges the sequence of
statements
 Code generation stage gets inputs from code optimization phase and produces the
page code or object code as a result
 A symbol table contains a record for each identifier with fields for the attributes of
the identifier
 Error handling routine handles error and reports during many phases

4.3 TOKEN
Tokens are symbolic names for the entities that make up the text of the program. A token is a
sequence of characters that can be identified as a single logical entity. The meaningful
collection of characters over the character set of the programming language ex:ID, Constant,
Keywords, Operators, Punctuation, Literal String

A programming token is the basic component of source code. Characters are categorized as
one of five classes of tokens that describe their functions (constants, identifiers, operators,
keywords, and separators) in accordance with the rules of the programming language

4.3.1 WHAT ARE THE TYPES OF TOKENS


C tokens are of six types. They are,
 Keywords (eg: int, while),
 Identifiers (eg: main, total),
 Constants (eg: 10, 20),
 Strings (eg: “total”, “hello”),
 Special symbols (eg: (), {}),
 Operators (eg: +, /,-,*)

4.3.2 TOKENIZATION
Tokenization is the act of breaking up a sequence of strings into pieces such as words,
keywords, phrases, symbols and other elements called tokens. Tokens can be individual
words, phrases or even whole sentences. Tokenization is used in computer science, where it
plays a large part in the process of lexical analysis.

4.4 LEXEMES
Lexemes are part of the input stream from which tokens are identified. An invalid or illegal
token produces an error. A lexeme is one of the building blocks of language. A lexeme is a
sequence of characters in the source program that matches the pattern for a token and is
identified by the lexical analyzer as an instance of that token. Lexeme is basically the unit of
a token and it is basically sequence of characters that matches the token and helps to break
the source code into tokens.
4.5 COMPARE AND CONTRAST
TOKEN LEXEME
KEYWORD
if
LEFT PARENTHESIS
(
IDENTIFIER
y
COMPARISON
=
IDENTIFIER
t
RIGHT PARENTHESIS
)
IDENTIFIER
y
ASSGNMENT
=
IDENTIFIER
y
ARITHMATIC
_
INTEGER
3
SEMICOLON ;

ILLUSTRATION

4.6 COMPILER ERROR HANDLING ROUTINE


In the compiler design process error may occur in all the below-given phases, Most common
errors are invalid character sequence in scanning, invalid token sequences in type, scope
error, and parsing in semantic analysis.

The error may be encountered in any of the above phases. After finding errors, the stage
needs to deal with the errors to continue with the compilation process. These errors need to
be reported to the error handler which handles the error to perform the compilation process.
Generally, the errors are reported in the form of message.
 Lexical analyzer: Wrongly spelled tokens
 Syntax analyzer: Missing parenthesis
 Intermediate code generator: Mismatched operands for an operator
 Code Optimizer: When the statement is not reachable
 Code Generator: Unreachable statements
 Symbol tables: Error of multiple declared identifiers
4.7 TYPES OF COMPILERS
1. Native code compiler: The compiler used to compile a source code for same type of
platform only. The output generated by this type of compiler can only be run on the
same type of computer system and Os that the compiler itself runs on.
2. Cross compiler: The compiler used to compile a source code for different kinds
platform. Used in making software’s for embedded systems that can be used on
multiple platforms.
3. A cross compiler gives you the advantage of creating code that could be run on
machines other than the one on which source is compiled .
Almost all the compilers we use today are cross compilers .
4. Source to source compiler: the compiler that takes high-level language code as
input and outputs source code of another high- level language only.Unlike other
compilers which convert high level language into low level machine language, it can
take up a code written in Pascal and can transform it into C-conversion of one high
level language into another high level language having same type of abstraction .
Thus,it is also known as transpiler. As the name suggests such compilers convert the
source code written in one programming language into another programming
language that operates at almost same level of abstraction .
5. One pass compiler: It is a type of compiler that compiles the whole process in only
one-pass and then go for the next read.
6. Threaded code compiler: The compiler which simply replace a string by an
appropriate binary code.
7. Incremental compiler: The compiler which compiles only the changed lines from
the source code and update the object code.
8. Source compiler: The compiler which converts the source code high level language
code in to assembly language only
9. Decompiler: Now they are interesting , these compilers decompile the code , that is
convert machine language to source code but at a relatively low level of abstraction
. They are an important tool in software reverse engineering .

4.7.1 THE NEED FOR COMPILER


 Compiler verifies entire program, so there are no syntax or semantic errors
 The executable file is optimized by the compiler, so it is executes faster
 Allows you to create internal structure in memory
 There is no need to execute the program on the same machine it was built
 Translate entire program in other language
 Generate files on disk
 Link the files into an executable format
 Check for syntax errors and data types
 Helps you to enhance your understanding of language semantics
 Helps to handle language performance issues
 Opportunity for a non-trivial programming project
 The techniques used for constructing a compiler can be useful for other purposes as
well

4.7.2 APPLICATION OF COMPILERS


 Compiler design helps full implementation Of High-Level Programming Languages
 Support optimization for Computer Architecture Parallelism
 Design of New Memory Hierarchies of Machines
 Widely used for Translating Programs
 Used with other Software Productivity Tools
4.7.3 ATTRIBUTES OF A COMPILER
MAIN TASKS PERFORMED BY THE COMPILER ARE:
 Breaks up the up the source program into pieces and impose grammatical structure on
them
 Allows you to construct the desired target program from the intermediate
representation and also create the symbol table
 Compiles source code and detects errors in it
 Manage storage of all variables and codes.
 Support for separate compilation
 Read, analyze the entire program, and translate to semantically equivalent
 Translating the source code into object code depending upon the type of machine

4.8 INTERPRETER
There are two ways to run programs written in a high-level language. The most common is to

1) Compile the program


2) The other method is to pass the program through an interpreter.

An interpreter translates high-level instructions into an intermediate form, which it then


executes immediately. The advantage of an interpreter is that it does not need to go through
the compilation stage during which machine instructions are generated. This process can be
time-consuming if the program is long. The interpreter, on the other hand, can immediately
execute high-level programs.

4.8.1 DIFFERENCE BETWEEN COMPILER AND INTERPRETER


A compiler is a translator which transforms source language (high-level language) into object
language (machine language). In contrast with a compiler, an interpreter is a program which
imitates the execution of programs written in a source language.

COMPILER INTERPRETER
A compiler is a program which coverts the interpreter takes a source program
entire source code of a programming language and runs it line by line, translating
into executable machine code for a CPU. each line as it comes to it.

Compiler takes large amount of time to analyze Interpreter takes less amount of
the entire source code but the overall time to analyze the source code but
execution time of the program is comparatively the overall execution time of the
faster. program is slower.

Compiler generates the error message only


after scanning the whole program, so Its Debugging is easier as it
debugging is comparatively hard as the error continues translating the program
can be present any where in the program. until the error is met

No intermediate object code is


Generates intermediate object code. generated.

Examples: C, C++, Java Examples: Python, Perl


4.8.2 SOURCE LANGUAGE
Source language is the language being translated from; it is the antonym of the target
language, which is the language that we want to translate, it is the language
human/programmer use for inputting the source code

4.8.3 TARGET LANGUAGE


Target language, also called the object language, it is the machine. It is the antonym
of source language, it is the language we want to arrive/derive. This is the language that the
machine will comprehend to perform our instruction/task.

5.1 ASSEMBLER
An assembler is a program that converts assembly language into machine code. It takes the
basic commands and operations from assembly code and converts them into binary code that
can be recognized by a specific type of processor. Assemblers are similar to compilers in that
they produce executable code.

5.1.1 ASSEMBLY LANGUAGE (ASM)


An assembly language is a low-level programming language for microprocessors, assembly
language implements a symbolic representation of the machine code needed to program a
given CPU architecture.

5.1.2 ADVANTAGES OF ASSEMBLY LANGUAGE


1. Programs written in machine language are replaceable by mnemonics which are easier to
remember.
2. Memory Efficient.
3. It is not required to keep track of memory locations.
4. Faster in speed.
5. Easy to make insertions and deletions.
6. Hardware Oriented.
7. Requires fewer instructions to accomplish the same result.

5.1.3 DISADVANTAGES OF ASSEMBLY LANGUAGE


1. Long programs written in such languages cannot be executed on small sized computers.
2. It takes lot of time to code or write the program, as it is more complex in nature.
3. Difficult to remember the syntax.
4. Lack of portability of program between computers of different makes.
5. No SDKs (System Development Kit).

5.1.4 SIGNIFICANCE OF ASSEMBLY LANGUAGE


 Assembly gives direct and complete control over system hardware:
 Writing device drivers.
 Operating system design.
 Embedded systems programming, e.g. aviation industry.
 It is most suitable for writing interrupt service routines and other memory resident
programs

5.1.5 ASSEMBLY INSTRUCTIONS AND INTERPRETATIONS


5.1.5.1 MOV
MOV is an X86 assembly language instruction, it is meant to move data between registers and
memory
1) MOV AX,45H; Immediate constant 45H is transferred to AX
2) MOV TOTAL, 48 Transfer the value 48 in the
3) MOV AL, 10 Transfer the value 10 to the AL register
5.1.5.2 ADD
The add instruction adds together its two operands, storing the result in its first operand.
Note, whereas both operands may be registers, at most one operand may be a memory
location

1) ADD MARKS, 10 Add 10 to the variable MARKS


2)ADD BYTE_VALUE,65 An immediate operand 65 is added
3) ADD AH, BH Add the content of the BH register into the AH
register

5.1.5.3 INC
The INC instruction is used for incrementing an operand by one. It works on a single operand
that can be either in a register or in memory.

1) INC COUNT Increment the memory variable COUNT


2) INC EBX Increment 32-bit register
3) INC DL Increment 8-bit register

5.1.6 TYPES OF ASSEMBLER


5.1.6.1 ONE PASS ASSEMBLER
One pass assemblers perform single scan over the source code. If it encounters any undefined
label, it puts it into symbol table along with the address so that the label can be replaced
later when its value is encountered. One pass assembler tends to be faster as two pass
assembler requires rescanning

5.1.6.2 TWO PASS ASSEMBLER


On the other hand two pass assembler performs two sequential scans over the source code. It
divides the procedure into two steps.

PASS 1: creates table for undefined symbols/labels and their values (assign addresses to all
statements in the program)

PASS 2: generates the machine code (save the values assigned to all labels for use in pass 2)

5.1.6.3 MULTI-PASS ASSEMBLER


Multi-pass assembler means more than one pass is used by assembler. M u l t i p a s s
assembler is used to eliminate forward references in symbol definition. It creates a number
of passes that is necessary to process the definition of symbols. Multi pass assembler does the
work in two pass by resolving the forward references. Multi-pass assemblers create a table
with all symbols and their values in the first passes, and then use the table in later passes to
generate code.

FIRST PASS
•Scans the code
•Validates the tokens
•Creates a symbol table

SECOND PASS
•Solves forward references
•Converts the cod
5.1.6.4 RESIDENT ASSEMBLER
If an assembler which runs on a computer and produces the machine codes for the same
computer then it is called resident assembler

5.1.6.5 CROSS ASSEMBLER


A cross assembler is a program which generates machine code for a processor other than the
one it is currently run on. A cross compiler is a compiler capable of creating executable code
for a platform other than the one on which the compiler is running.

5.1.6.6 TASM
Turbo Assembler (TASM) is a computer assembler (software for program development)
developed by Borland which runs on and produces code for 16- or 32-bit x86 DOS or Microsoft
Windows. It can be used with Borland's high-level language compilers, such as Turbo Pascal,
Turbo Basic, Turbo C and Turbo C++.

5.1.6.7 ASSEMBLY ERRORS


(1) SYMBOL TABLE OVERFLOW
This is reported when the symbol table runs out of space

(2) OBJECT OVERFLOW


This is reported when the assembler runs out of room in its output object-code segment

(3) MEMORY OPERAND REQUIRED


This is reported when an operand to a floating-point must be a memory operand, and the
operand you've provided isn't one

(4) PARENTHESIS/BRACKET MISMATCH


This is reported when there is a lack of balance of parentheses ( ) or brackets [ ] in an
operand expression, there are too many left-sides, too many right-sides, or the
brackets are interleaved illegally

(5) BAD INDEX REGISTER


This is reported when you attempt to use a register other than
SI, DI, BX, or BP for indexing

(6) ILLEGAL CONSTANT


There are syntax errors in a numeric constant

5.1.7 ASSEMBLY LANGUAGE OPCODES


MNEMONIC INSTRUCTION
AAC Alter All Commands
AAD Alter All Data
AAO Add And Overflow
AAR Alter at Random
AB Add Backwards
ABC AlphaBetize Code
ABR Add Beyond Range
ACC Advance CPU clock
IU Ignore User(s)
IZ Ignore Zeroes
5.1.8 MACHINE LANGUAGE
Machine code or machine language is a set of instructions, consisting of binary, executed
directly by a computer's central processing unit. Machine code or machine language is a set of
instructions executed directly by a computer's central processing unit (CPU). Each instruction
performs a very specific task, such as a load, a jump, or an ALU operation on a unit of data in
a CPU register or memory. Machine Language are numeric codes for operations which a
computer can respond to directly. The codes are strings of 0s and 1s, or binary digits (“bits”)

5.2 ASSEMBLY PROGRAMS


5.2.1 ASSEMBLY PROGRAM TO ADD TWO NUMBERSDATA SEGMENT

AFTER EXECUTION

MNEMONICS MEMORY ADDRESS COMMENT


1. MOV SI, 500: assign 500 to SI
2. MOV CL, [SI]: load data from offset SI to register CL
3. INC SI: increase value of SI by 1
4. MOV CH, 00: assign 00 to register CH
5. MOV AL, 00: assign 00 to register AL
6. MOV BL, [SI]: load data from offset SI to register BL
7. TEST BL, 01: AND register BL with 01
8. JNZ 413: jump to address 413 if not zero
9. ADD AL, BL: add contents of register AL and BL
10. INC SI: increase value of SI by 1
11. LOOP 40A: jump to 40A if CX not zero and CX=CX-1
12. MOV [600], AL: store the value of register AL to
offset 600
13. HLT: end
5.2.4 DECLARATION OF INTEGER IN ASSEMBLY LANGUAGE
DB – Define Byte (Size – 1 Byte)
DW – Define Word (Size – 2 Byte)
DD – Define Double word (Size - 4 Bytes)
DQ – Define Quad word (Size – 8 Bytes)
DT – Define Ten Bytes (Size – 10 Bytes)

5.3 EXTENDING SIGNED AND UNSIGNED INTEGERS


 Since moving data between registers of different sizes is illegal, you mustsign-extend
integers to convert signed data to a larger size.
 Sign-extending means copying the sign bit of the unextended operand to all bits of the
operand's next larger size.
 This widens the operand while maintaining its sign and value.
 The four instructions presented below act only on the accumulator register (AL, AX, or
EAX), as shown

Instruction Sign-extend FORMAT


CBW (convert byte to word) AL to AX CBW AX, AL
CWD (convert word to doubleword) AX to DX:AX CWD DX:AX, AX
CWDE (convert word to doubleword extended) AX to EAX CWDE EAX, EAX
CDQ (convert doubleword to quadword) EAX to EDX:EAX CDQ EDX:EAX, EAX

5.3.1 BYTE
The BYTE directive tells the assembler to reserve a block of storage and remember its length
in bytes. The length is determined by the number of bytes in the initializer, which could be
numbers between 0-255 decimal, or characters in single quotes

5.3.2 WORD
Word generally means the number of bits that can be transferred at one time on the data bus,
and stored in a register, In terms of MIPS, a word is 32 bits, that is, 4 bytes

5.3.3 QUAD WORD


It is a define directive in assembly language for reserving space, it Allocates 8-byte integers
used with 8087-family coprocessor instructions.

6.1 INTERRUPT
An interrupt is a signal to the processor, to gets the attention of the CPU and is usually
generated when I/O is required emitted by hardware or software indicating an event that
needs immediate attention. An interrupt alerts the processor to a high-priority condition
requiring the interruption of the current code the processor is executing

6.1.1 WHAT HAPPENS WHEN AN INTERRUPT IS CALLED


When an interrupt occurs, it causes the CPU to stop executing the current program. The
control then passes to a special piece of code called an Interrupt Handler or Interrupt Service
Routine. The interrupt handler will process the interrupt and resume the interrupted
program.
6.1.2 HOW INTERRUPT IS SERVICED
1) The processors registers firstly save the status of the program currently executing on the
stack or the program counter will be saved

2) The processor then services the interrupt by branching to a special service routine written
to handle that particular interrupt. In order words the processor responds by suspending its
current activities, saving its state, and executing a function called an interrupt handler (or an
interrupt service routine, ISR) to deal with the event, by executing a log of algorithm, after
the interrupt handler finishes, the processor resumes from it previous state

3) Finally processor passes control to resume previous executing instruction

6.1.3 TYPES OF INTERRUPTS


Although interrupts have highest priority than other signals, there are many type of interrupts
but basic type of interrupts are

6.1.3.1 HARDWARE INTERRUPT


Hardware interrupts are used by devices to communicate that they require attention from the
operating system, the act of initializing hardware interrupt is referred to as an interrupt
request (IRQ), hardware interrupt are asynchronous and can occur in the middle of instruction

6.1.3.2 SOFTWARE INTERRUPT


Software interrupts occurs when an application program terminates or request certain
services from the operating system. It is considered as the way to communicate with the
kernel or invoke system call during error. A software interrupt is also called trap

6.1.3.3 PROCESSOR INTERRUPT (EXEPTION)


Software interrupts is a type of interrupt that is caused either by a special instruction in the
instruction set or by an exceptional condition in the processor itself.

6.2 SYSTEM BUS


System bus provides communication path for the data and control signals moving between the
major components of the computer system.

6.2.1 HOW DOES A SYSTEM BUS WORK


System bus is a single computer bus that connects the major components of a
computer system, combining the functions of a data bus to carry information, an
address bus to determine where it should be sent, and a control bus to determine its
operation. The system bus is a pathway composed of cables and connectors used to carry data
between a computer microprocessor and the main memory. The system bus works by
combining the functions of the three main buses: namely, the data, address and
control buses, each of the three buses has its separate characteristics and responsibilities.

6.2.2 ARRANGEMENT OF BUS IN A COMPUTER SYSTEM


6.2.3 TYPES OF SYSTEM BUS
THE SYSTEM BUS COMBINES THE FUNCTIONS OF THE THREE MAIN BUSES, WHICH ARE AS
FOLLOWS:

6.2.3.1 The address bus is used to specify memory locations for the data being
transferred.

6.2.3.2 The data bus, which is a bidirectional path, carries the actual data between the
processor, the memory and the peripherals.

6.2.3.3 The control bus carries the control, timing and coordination signals to manage the
various functions across the system.

6.3 SYMBOL TABLE


symbol table is an implementation of a data structure used by a language translator such as
a compiler or interpreter, where each identifier (symbol) in a program's source code is
associated with information relating to its declaration or appearance in the source.
Symbol table is an important data structure created and maintained by compilers in order to
store information about the occurrence of various entities such as variable names, function
names, objects, classes, interfaces, etc. Symbol table is used by both the analysis and the
synthesis parts of a compiler.

Symbol table is an important data structure created and maintained by compilers in order to
store information about the occurrence of various entities such as variable names, function
names, objects, classes, interfaces, etc.

Symbol table contains information to locate and relocate symbolic definitions and references.
The assembler creates the symbol table section for the object file. It makes an entry in the
symbol table for each symbol that is defined or referenced in the input file and is needed
during linking. Symbol table is then used by the link editor during relocation

6.4 SPOOLING
Spooling, an acronym of Simultaneous Peripheral Operation On-line (SPOOL), puts data into a
temporary working area so it can be accessed and processed by another program or resource.
Spooling is a process in which data is temporarily held to be used and executed by a
device, program or the system. Data is sent to and stored in memory or other volatile storage
until the program or computer requests it for execution.

Spooling is useful because devices access data at different rates. The spool buffer provides a
waiting station where data can rest while a slower device, such as a printer, catches up.
When the slower device is ready to handle a new job, it can read another batch of
information from the spool buffer. Spooling is a specialized form of multi-programming for
the purpose of copying data between different devices. In contemporary systems, it is
usually used for mediating between a computer application and a slow peripheral, such as a
printer.

6.4.1 ADVANTAGES OF SPOOLING


 The spooling operation uses a disk as a very large buffer,so it is very useful to send
large data.
 Spooling is capable of overlapping I/O operation for one job with processor operations
for another job.
6.4.2 DISADVANTAGES OF SPOOLING
* The main disadvantage of Spooling is that it is very difficult to debug.
* Due to lack of protection scheme, one batch job can affect the pending jobs.

6.5 BUFFER
Buffer is a region of a physical memory storage used to temporarily store data while it is
being moved from one place to another. However, a buffer may be used when moving data
between processes within a computer. A buffer contains data that is stored for a short
amount of time, typically in the computer's memory (RAM). The purpose of a buffer is to hold
data right before it is used. For example, when you download an audio or short video file
from whatapp, it may load the first 20% of it into a buffer and then begin to play immediately
while downloading is not yet completed.

6.5.1 BUFFERING
Preloading data into a reserved area of memory (the buffer). For example streaming audio or
video from the Internet, buffering refers to downloading a certain amount of data before
starting to play the music or movie.

6.5.2 ADVANTAGES OF BUFFERING


1) Buffering is used to improve several other areas of computer performance as well.
2) Most hard disks use a buffer to enable more efficient access to the data on the disk.
3) Video cards send images to a buffer before they are displayed on the screen (known as a
screen buffer).

6.5.3 DISADVANTAGES OF BUFFERING


1) It is costly and impractical to have the buffer be the exact size required to hold the
number of elements
2) Buffers have a fixed size

6.6 DIFFERENCE BETWEEN SPOOLING AND BUFFERING


Spooling and buffering are the two ways by which I/O subsystems improve the performance
and efficiency of the computer by using a storage space in main memory or on the disk. The
basic difference between Spooling and Buffering is that Spooling overlaps the I/O of one job
with the execution of another job while the buffering overlaps I/O of one job with the
execution of the same job

BASIS FOR
SPOOLING BUFFERING
COMPARISON

Basic Spooling overlap the I/O of Buffer overlaps the I/O of


one job with the one job with the
computation of another job. computation of the same
job.

Full form Simultaneous peripheral No full form.


operation online

Efficient Spooling is more efficient Buffering is less efficeint


than buffering. than spooling.

Size Spooling considers disk as a Buffer is a limited area in


huge spool or buffer. main memory.
6.7 CACHE
Cache is a memory bank that bridges main memory and the processor. Comprising faster
static RAM (SRAM) chips than the dynamic RAM (DRAM) used for main memory,
the cache allows instructions to be executed and data to be read and written at higher speed.

6.7.1 CACHE VS BUFFER


1. Cache is a high-speed storage area while a buffer is a normal storage area on RAM for
temporary storage.

2. Cache is made from static RAM which is faster than the slower dynamic ram used for a
buffer.

3. The buffer is mostly used for input/output processes while the cache is used during reading
and writing processes from the disk.

4. Cache can also be a section of the disk while a buffer is only a section of the RAM.

5. A buffer can be used in keyboards to edit typing mistakes while the cache cannot.

You might also like