RMK Group A4 PPT - MPMC - Ec8691 - Unit 1
RMK Group A4 PPT - MPMC - Ec8691 - Unit 1
This document is confidential and intended solely for the educational purpose of
RMK Group of Educational Institutions. If you have received this document
through email in error, please notify the system manager. This document
contains proprietary information and is intended only to the respective group /
learning community as intended. If you are not the addressee you should not
disseminate, distribute or copy through e-mail. Please notify the sender
immediately by e-mail if you have received this document by mistake and delete
this document from your system. If you are not the intended recipient you are
notified that disclosing, copying, distributing or taking any action in reliance on
the contents of this information is strictly prohibited.
EC8691
MICROPROCESSORS
&
MICROCONTROLLERS
Department: CSE & IT
Created by:
S.D. Lalitha, Assistant Professor
Date: 01.9.2021
Table of Contents
Course Objectives
Pre Requisites
Syllabus
Course outcomes
CO- PO/PSO Mapping
Lecture Plan
Activity based learning
Unit 1 :
Lecture Notes
Lecture Notes – Links to Videos
Lecture Notes – e book reference
Lecture Notes – PPTs
Lecture Notes - Quiz
Lecture Notes - References
Assignments
Part A Q & A (with K level and CO)
Part B Qs (with K level and CO)
Supportive online Certification courses
Real time Applications in day to day life and to Industry
Contents beyond the Syllabus
Assessment Schedule
Prescribed Text Books & Reference Books
Mini Project suggestions
Course Objectives
CS8251 Programming in C
UNIT IV MICROCONTROLLER
Architecture of 8051 – Special Function Registers(SFRs) – I/O Pins Ports and Circuits
– Instruction set – Addressing modes – Assembly language
programming.
CO PO PO PO PO PO PO PO PO PO PO PO PO PS PS PS
1 2 3 4 5 6 7 8 9 10 11 12 O1 O2 O3
1 3 3 3 - - - - - - - - - 3 - -
2 3 2 2 - - - - - - - - - 3 - -
3 3 3 3 - - - - - - - - - 3 - -
4 3 3 3 - - - - - - - - - 3 - -
5 3 2 2 - - - - - - - - - 3 - -
6 3 3 3 - - - - - - - - - 3 - -
Unit I - THE 8086
MICROPROCESSOR
Lecture Plan
per
Ses No. Proposed Actual tai Taxon Mode
Topics to be
sion of date Lecture nin omy of
covered
No. Per Date g level Deliver
iod CO y
s
architecture
Assembly language
6 9 27.08.2021 27.08.2021 1 K3 PPT
programming
Modular Programming
Relocation
Stacks – Procedures –
Macros – Interrupts
8 9 31.08.2021 31.08.2021 1 K2 PPT
and interrupt service
routines
https://drive.google.com/file/d/1P0Z7tY2dNhWc0oOalD0ROIO7wKUCRo
bI/view?usp=sharing
YouTube Link:
https://www.youtube.com/watch?v=Uh7jx_Feq4w
YouTube Link:
https://www.youtube.com/watch?v=0e52QKSE1YU
Lecture Notes
THE 8086 MICROPROCESSOR
What is a microprocessor?
Microprocessors of different word size with varying decrease of capabilities are available.
Microprocessor comprises of all the functional components of the central processing unit of
a general purpose computer. In other words, functionally it is equivalent to a CPU.
• Cost: The most important characteristics of a microcomputer is its low cost. Because of the
widespread use of microprocessors, the volume of production is very high. That is why,
microprocessor chips are available at fairly low prices.
• Reliability: Another important property of VLSI devices which has also been in
herniated by microprocessors is extreme reliability. It has been established that the
failure rate of an IC is fairly uniform at the package level, regardless of its
complexity.
Lecture Notes
• Size: The second important features of a microprocessor is its small size. As a
result of improvement in fabrication technology, VLSI, electronic circuitry has
become so dense that a minute silicon chip can contain hundred and thousands of
transistors constituting the microprocessor. Its size does not exceed a few inches on
any side, even in the packaged form.
i) MEMORY: The memory section usually consists of a mixture of RAM and ROM. It
may also have magnetic floppy disks, magnetic hard disks, or laser optical disks.
Memory has two purposes. The first purpose is to store the binary codes for the
sequence of instructions you want the computer to carry out. When you write a
computer program, what you are really doing is just writing a sequential list of
instructions for the computer. The second purpose of the memory is to store the
binary-coded data with which the computer is going to be working.
ii) INPUT/OUTPUT: The input/output or I/O section allows the computer to take in
data from the outside world or send data to the outside world. These allow the user
and the computer to communicate with each other. The actual physical dev ices used
to interface the computer buses to external systems are often called ports.
iii) CPU: The central processing unit or CPU controls the operation of the computer.
It fetches binary-coded instruction of the computer. It fetches binary-coded
instructions from memory, decodes the instructions into a series of simple actions,
and carries out these actions. The CPU contains an arithmetic logic unit, or ALU.
Which can perform add, subtract, OR, AND, invert, or exclusive-OR operations on
binary words when instructed to do so. The CPU also contains an address counter
which is used to hold the address of the next instruction or data to be fetched from
memory, general-purpose registers which are used for temporary storage of binary
data, and circuitry which generates the control bus signals
Lecture Notes
iv) ADDRESS BUS: The address bus consists of 16, 20, 24, or more parallel signal
lines. On these lines the CPU sends out the address of the memory location that is
to be written to or read from. The number of address lines determines the number
of memory locations that the CPU can address. If the CPU has N address lines, then
it can directly address 2N memory locations.
v) DATA BUS: The data bus consists of 8, 16, 32 or more parallel signal lines. As
indicated by the double-ended arrows on the data bus line, the data bus lines are bi-
directional. This means that the CPU can read data in on these lines from memory or
from a port as well as send data out on these lines to memory location or to a port.
Many devices in a system will have their outputs connected to the data bus, but the
outputs of only one device at a time will be enabled.
vi) CONTROL BUS: The control bus consists of 4-10 parallel signal lines. The CPU
sends out signals on the control bus to enable the outputs of addressed memory
devices or port dev ices. Typical control bus signals are memory read, memory write,
I/O read, and I/O writer. To read a byte of data from a memory location, for
example, the CPU sends out the address of the desired byte on the address bus and
then sends out a memory read signal on the control bus.
Lecture Notes
1.2 Microprocessor Architecture
The BIU makes the system bus signals available for external inter fac ing of devices. The
other words, this unit is responsible for establishing communications with external devices
and peripherals including memory via bus. The incomplete physical address which is 20 bits
long is generated using segment and offset registers each 16bit long.
For generating a physical address from contents of these 2 registers, the content of a
segment register is also called as offset address is added to produce 20bit physical address.
For e.g. if the segment address is 1005H & the offset is 5555H then the physical address is
calculated as
on adding both,
i.e. 1 5 5 A 5 H
The segment register indicates the base address of a particular segment while the offset
indicates the distance of the required memory location in the segment from the base
address. the segment address value is to be taken from an appropriate segment register
depending upon whether code, data or stack are to be accessed, while the offset may be
the content of IP, BX, SI, DI, SP or an immediate 16-bit value, depending upon the
addressing mode.
In 8086 it is possible to achieve the overlapped fetch & the execution cycles. While the
fetched instruction is executed internally, the external bus is used to fetch the machine code
of next instruction & arrange it in a queue called pre coded instruction byte queue.
Lecture Notes
It is a 6 byte long First In First Out structure. The instruction from the queue are
taken for decoding sequentially once the byte is decoded the queue is rearranged by
pushing it out & the queue status is checked for the possibility of next opcode fetch
cycle. While the opcode is fetched by the BIU the EU executes the previously
decoded instruction concurrently. The BIU along with the EU thus forms a
PIPELINE. The bus interface unit manages the complete interface of execution unit
memory & input devices of course under the control of timing & control unit.
EU (EXECUTION UNIT):
The execution unit contains register set of 8086 except segment register & IP. It has
a 16 bit ALU able to perform arithmetic & logic operations. The 16-bit flag register
reflects the result of execution by ALU. The decoding unit decodes the opcode bytes
issued from the instruction byte queue.
The timing & control unit derives the necessary control signals to execute the
instruction opcode retrieved from the queue depending upon the information unit
may pass the results to the BIU for storing them in memory.
All the registers of 8086 are 16-bit registers. The general purpose registers, can be
used either 8- bit registers or 16-bit registers used for holding the data, variables
and intermediate results temporarily or for other purpose like counter or for storing
offset address for some
Lecture Notes
Fig. 1. Register set of 8086
particular addressing modes etc. The special purpose registers are used as segment
registers, pointers, index registers or as offset storage registers for particular
addressing modes.
AX Register: Accumulator register consists of two 8-bit registers AL and AH, which
can be combined together and used as a 16- bit register AX. AL in this case contains
the low-order byte of the word, and AH contains the high-order byte. Accumulator
can be used for I/O operations, rotate and string manipulation.
BX Register: This register is mainly used as a base register. It holds the starting
base location of a memory region within a data segment. It is used as offset storage
for forming physical address in case of certain addressing mode.
CX Register: It is used as default counter - count register in case of string and loop
instructions.
Lecture Notes
DX Register: Data register can be used as a port number in I/O operations and
implicit operand or destination in case of few instructions. In integer 32-bit multiply
and div ide instruction the DX register contains high-order word of the initial or
resulting number.
Segment registers: 1Mbyte memory is div ided into 16 logical segments. The
complete 1Mbyte memory segmentation is as shown in fig 1.4. Each segment
contains 64Kbyte of memory. There are four segment registers.
Stack segment (SS) is a 16-bit register containing address of 64KB segment with
program stack. By default, the processor assumes that all data referenced by the
stack pointer (SP) and base pointer (BP) registers is located in the stack segment.
SS register can be changed directly using POP instruction. It is used for addressing
stack segment of memory. The stack segment is that segment of memory, which is
used to store stack data.
Data segment (DS) is a 16-bit register containing address of 64KB segment with
program data. By default, the processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment.
DS register can be changed directly using POP and LDS instructions. It points to the
data segment memory where the data is resided.
Lecture Notes
Extra segment (ES) is a 16-bit register containing address of 64KB segment,
usually with program data. By default, the processor assumes that the DI register
references the ES segment in string manipulation instructions. ES register can be
changed directly using POP and LES instructions. It also refers to segment which
essentially is another data segment of the memory. It also contains data.
Pointers and index registers: The pointers contain within the particular
segments. The pointers IP, BP, SP usually contain offsets within the code, data and
stack segments respectively.
Stack Pointer (SP) is a 16-bit register pointing to program stack in stack segment.
Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and
register indirect addressing, as well as a source data addresses in string
manipulation instructions. Destination
Index (DI) is a 16-bit register. DI is used for indexed, based indexed and register
indirect addressing, as well as a destination data address in string manipulation
instructions.
Flag Register:
Flag Register determines the current state of the processor. They are modified
automatically by CPU after mathematical operations, this allows to determine the
type of the result, and to determine conditions to transfer control to other parts of
the program.
Lecture Notes
The 8086 flag register as shown in the fig. 8086 has 9 active flags and they are
divided into two categories: 1. Conditional Flags 2. Control Flags
Conditional Flags
Carry Flag (CY): This flag indicates an overflow condition for unsigned integer
arithmetic. It is also used in multiple-precision arithmetic.
Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits
of the result contains even number of 1’s, the Parity Flag is set and for odd number
of 1’s, the Parity flag is reset.
Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero else it
is reset.
Sign Flag (SF): In sign magnitude format the sign of number is indicated by MSB bit.
If the result of operation is negative, sign flag is set.
Control Flags
Control flags are set or reset deliberately to control the operations of the execution
unit. Control flags are as follows:
Trap Flag (TF): It is used for single step control. It allows user to execute one
instruction of a program at a time for debugging. When trap flag is set, program can
be run in single step mode.
Lecture Notes
Interrupt Flag (IF): It is an interrupt enable/disable flag. If it is set, the maskable
interrupt of 8086 is enabled and if it is reset, the interrupt is disabled. It can be set
by executing instruction sit and can be cleared by executing CLI instruction.
Direction Flag (DF): It is used in string operation. If it is set, string bytes are
accessed from higher memory address to lower memory address. When it is reset,
the string bytes are accessed from lower memory address to higher memory
address.
Fig. The complete bit configuration of 8086 flag register is shown below:
Lecture Notes
Memory Segmentation:
The 16bit content of segment register actually points to the starting location of
particular segment. To address a specific given location within a segment, we need
an offset address. The offset is also a 16 bit long so that the max offset value can be
FFFFH & the max size of any segment is thus 64K locations. The segment may be
overlapped in some cases.
Suppose a segment starts at a particular address and its max size can be 64K bytes.
But If another segments starts before its 64K bytes location of the first segment, the
2 segments are said to be OVERLAPPING SEGMENTS The area of memory from
the start of second segment to the possible end of the first segment is called as
overlapped segment area. The main advantages of segmented memory are
*allows the placing oh code, data &stack portions of the same program in different
parts of memory for data & code protection
*Permits a program &/or its data to be into different areas of memory each time
program is executed i.e. provision for relocation may be done.
Lecture Notes
Fig. Memory Segmentation
Lecture Notes
Fig: Non-Overlapping and Overlapping Segments
1. It is 16-bit microprocessor
2. It has a 16-bit data bus, so it can read data from or write data to memory and
ports either 16-bit or 8-bit at a time.
3. It has 20-bit address bus and can access up to 220 memory locations (1 MB).
7. It requires single phase clock with 33% duty cycle to provide internal timing.
a. Minimum mode
b. Maximum mode
The addressing modes describe the types of operands and the way they are
accessed for executing an instruction.
Sequential control flow instructions are the instructions, which after execution,
transfer control to the next instruction appearing immediately after it (in the
sequence) in the program. For example, the arithmetic, logic, data transfer and
processor control instructions are sequential control flow instructions.
The control transfer instructions, on the other hand, transfer control to some
predefined address or the address somehow specified in the instruction, after their
execution. For example, INT, CALL, RET and JUMP instructions fall under this
category.
Lecture Notes
The addressing modes for sequential control transfer instructions are:
In the above example, 0005H is the immediate data. The immediate data may be 8-
bit or 16-bit in size.
2. Direct: In the direct addressing mode a 16-bit memory address (offset) is directly
specified in the instruction as a part of it.
Here, data resides in a memory location in the data segment, whose effective
address may be completed using 5000H as the offset address and content of DS as
segment address. The effective address here, is 10H * DS + 5000H.
Register Indirect: Sometimes, the address of the memory location, which contains
data or operand, is determined in an indirect way, using the offset register. This
mode of addressing is known as register indirect mode. In this addressing mode, the
offset address of data is in either BX or SI or DI register. The default segment is
either DS or ES.
Lecture Notes
The data is supposed to be available at the address pointed to by the content of any
of the above registers in the default data segment.
Here, data is present in a memory location in DS whose offset address is in BX. The
effective address of the data is given as 10H * DS+[BX].
5. Indexed: In this addressing mode, offset of the operand is stored in one of the
index registers. DS and ES are the default segments for index registers, SI and DI
respectively. This is a special case of register indirect addressing mode.
Here, data is available at an offset address stored in SI in DS. The effective address,
in this case, is computed as 10*DS+[SI].
7. Based Indexed: The effective address of data is formed, in this addressing mode,
by adding content of a base register (any one of BX or BP) to the content of an
index register (any one of SI or DI). The default segment register may be ES or DS.
For control transfer instructions, the addressing modes depend upon whether the
destination is within the same segment or different one. It also depends upon the
method of passing the destination address to the processor.
Basically, there are two addressing modes for the control transfer instructions,
intersegment addressing and intrasegment addressing modes.
If the destination location lies in the same segment, the mode is called intrasegment
mode.
Lecture Notes
Fig. Addressing modes for Control Transfer Instructions
9. Intrasegment Direct Mode: In this mode, the address to which the control is to be
transferred lies in the same segment in which the control transfer instruction lies
and appears directly in the instruction as an immediate displacement value. In this
addressing mode, the displacement is computed relative to the content of the
instruction pointer IP.
The effective address to which the control will be transferred is given by the sum of
8 or 16-bit displacement and current content of IP. In the case of jump instruction, if
the signed displacement (d) is of 8-bits (i.e. –128<d<+128) we term it as short
jump and if it is of 16-bits (i.e-32, 768<d<+32,768) it is termed as long jump.
10. Intrasegment Indirect Mode: In this mode, the displacement to which the control
is to be transferred, is in the same segment in which the control transfer instruction
lies, but it is passed to the instruction indirectly. Here, the branch address is found
as the content of a register or a memory location. This addressing mode may be
used in unconditional branch instructions.
Lecture Notes
11. Intersegment Direct: In this mode, the address to which the control is to be
transferred is in a different segment.
This addressing mode provides a means of branching from one code segment to
another code segment. Here, the CS and IP of the destination address are specified
directly in the instruction.
12. Intersegment Indirect: In this mode, the address to which the control is to be
transferred lies in a different segment and it is passed to the instruction indirectly,
i.e. contents of a memory block containing four bytes, i.e. IP (LSB), IP(MSB),
CS(LSB) and CS (MSB) sequentially. The starting address of the memory block may
be referred using any of the addressing modes, except immediate mode.
The following examples explain forming of the effective addresses in the different
modes.
Ex: 1. The contents of different registers are given below. Form effective addresses
for different addressing modes.
Offset (displacement)=5000H
Shifting segment address four bits to the left is equivalent to multiplying it by 16D or
10H
Lecture Notes
i. Direct addressing mode:
MOV AX,[5000H]
_______
_______
________
_______
Lecture Notes
iii. Register relative:
DS : [5000+BX]
10H*DS 10000
offset +5000
[BX] +2000
________
________
DS : [BX + SI]
10H*DS 10000
BX] +2000
[SI] +3000
_______
_______
Lecture Notes
v. Relative based index:
DS : [BX+SI+5000]
10H*DS 10000
[BX] +2000
___________
___________
Instruction Formats
A machine language format has one or more no of fields associated with it. The first
field is called as operation code field or opcode field, which indicates the type of
operation to be performed by the CPU. The other is the operand field. The processor
executes the instruction using the information which resides in the fields.
There are size general formats of instructions in 8086 instruction set. the length of
the instruction may vary from one byte to 6 bytes. The instruction formats are
described as follows:
Lecture Notes
One-byte instruction
This format is only one byte long & may have the implied data or register operands.
Register To Register
This format is 2 bytes long, the first byte of the code specifies opcode & width of the operand
specifies by 'w' bit if 'w' bit is 0, the operand is of 8 bits & if w is 1, then the operand is of 16 bits the
second byte shows the register operand & R/M fields.
This format is also 2 bytes long similar to the register to register format except for the mod field.
MOD Indications
00 No displacement
01 8-bit displacement
10 16-bit displacement
11 Register operands
This type of instruction format contains one or two additional bytes for displacement along with 2-
byte format of the register to/from memory without displacement.
In this format the first byte as well as the 3bits from the second byte are used
for opcode. It contains one or two byte of immediate data.
This type of instruction format requires 5 or 6 bytes for coding the first 2 bytes
contains the information regarding opcode, MOD & R/M fields. The remaining 4-
bytes contains 2bytes of displacement & 2bytes of data.
E.g. MOV 1000H[2000H], 20H
The 8086 instructions are classified into the following main types:
Branch instructions
Loop instructions
String instructions
These instructions are used to transfer data from source operand to destination
operand
This instruction pushes the contents of the specified Register /memory location on
to the stack .The higher byte is pushed first followed by lower byte
e.g..
PUSH AX
PUSH DS
PUSH [5000H]
The instruction loads the specified register /memory location with the content of the
memory location of which the address is formed using the current stack segment &
stack pointer as usual. IT is exactly opposite to PUSH instruction
e.g.. POP AX
POP DS
POP [5000H]
Lecture Notes
XCHG - Exchange:
It is used for reading input port . The address of the input port may be specified in
the instruction directly or indirectly.
e.g., IN AL ,O3OOH
This instruction is used for writing to an output port .The address of output port may
be specified in instruction directly or implicitly in DX.
XLAT Translate
This instructions is used for finding out the codes in case of code conversion
problems offset of an operand in the specified register.
This instruction loads the DS or ES register & the specified destination register in the
instruction with the content of memory location specified as a source in the
instruction.
Lecture Notes
LAHF :Load from lower byte of flag:
Loads am register with the lower byte of flag register. This instruction may be used
to observe the status of all the conditions code flags at a time
This instruction sets or resets the condition code flags in the lower byte of the flag
register depending upon the corresponding bit positions in AH.
This instruction pushes the flag register on to the stack . first the upper byte & the
lower byte will be pushed on to the stack
The pop flag instruction loads the flag register completely from the word contents of
the memory location currently addressed by SP &SS
Arithmetic Instruction:
These instructions usually perform the arithmetic operations like addition subtraction
,multiplication &div ision along with respective ASCII & decimal adjust instructions.
The increment &decrement operations belongs to this type of instructions.
ADD:
This instruction performs the same operation as ADD instruction, but adds the carry
flag bit to the result.
INC : increment
This instruction increments the contents of the specified register or memory location
by 1
e.g.. INC AX
INC [BX]
INC [5000H]
Lecture Notes
DEC :Decrement
This instruction subtracts one from the contents specified register or memory
location.
DEC [5000H]
DEC [BX]
SUB :Subtract
The subtract instruction subtracts the source operand from the destination operand.
Source may be a register or a memory location or immediate data. Destination
operand may be a register or memory location. Memory to memory subtraction is
not possible.
This subtract with borrow instruction subtracts the source operand &borrow flag (EF) from
the destination operand
SUBB AX,[5000H]
CMP BX, CX
This instruction is executed after an ADD instruction that adds two ASCII coded
operands to give a byte of result in AL. This instruction converts the resulting
contents of AL to unpacked decimal digits
AAS instruction corrects the result in AL register after subtracting two operands
unpacked ASCII operands. the result is unpacked decimal formats.
This instruction after execution converts the product available in AL into unpacked
BCD format. This follows a multiplication instruction
The AAD instruction converts two unpacked BCD digits in AH & AL to the equivalent
binary number in AL .This adjustment must be made before dividing the two
unpacked BCD digits in AX by an unpacked BCD byte.
Lecture Notes
DAA Decimal adjust accumulator
This instruction is used to convert the result of addition of two packed BCD numbers
to a valid BCD number
This instruction converts the result of subtraction of two packed BCD numbers to a
valid BCD number.
Negative:
NEG: This negate instruction forms 2’s compliment of specified destination in the
instruction.
This instruction multiplies unsigned byte or word by the contents of AL. This most
significant word of the results is stored in AX.
e.g.. MUL BH : AX = AL X BH
This instruction multiplies a signed byte in source operand by a signed in AL or signed word
is source operand by single word in AXCS
e.g., IMUL BH
This instruction performs unsigned division. It divides an unsigned word or double word by
a 16 bit or 8-bit operand. The dividend must be in AX for 16-bit operation & divisor may be
specified using one of the addressing modes except immediate data. The quotient will be in
AL white AH will contain the remainder.
This instruction performs the same operation as the D IV instruction, but with signed
operands.
Logical Instructions
This type of instructions are used for carrying out bit by bit shift, rotate or basic logical
operations .All the condition code flags are affected depending upon the result .
This instruction logically AND the source operand that may be an immediate a register or a
memory location .Both operands cannot be memory locations or immediate operands
AND AX, BX
AND [0500H], DX
Lecture Notes
OR: Logical OR
The OR instruction carries out the OR operation in the same way as in the case of
AND operation
e.g. OR AX, BX
OR [5000H], 0008
OR AX ,0099H
e.g. NOT AX
NOT [5000H]
XOR AX, BX
Lecture Notes
TEST -Logical compile instruction:
This performs a bit by bit logical AND operation on the two operands. Each bit of the
result is then set to 1, if the corresponding bits of both operands are 1, else the
result bit is reset to 0. the result is not available for future use, bit flags are affected.
The affected flags are of CF, SF, ZF & PF. The operands may be register, memory or
immediate data.
These instructions shifts the operand word or byte bit by bit to the left & insert zeros
in the newly introduced least significant bits. The count is either 1 or specified by
register CL
Bit positions CF 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
operand 1 010110000110010
SHL result 0 101100001100100
This instruction performs bit wise rights on the operand word or byte that may
reside in a register or a memory location by the specified count in the instruction &
inserts zero in the shifted position.
Bit positions 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 CF
Operand 1110001001010001 0
After SHR with count=1 0111000100101000 1
Lecture Notes
SAR : Shift Arithmetic Right
This instruction performs rights shifts on the operand word or byte may be a register
or a memory location by the specified count in the instruction & inserts the most
significant bit if operand in the newly inserted positions.
operand 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 CF
count=1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1
Count=2 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0
This instruction rotates the contents of the destination operand to the right
(bitwise)either by one or count specified in CL, excluding carry. The LSB is pushed
into the carry flag & simultaneously it is transferred into the MSB position at each
operation.
This instruction rotates the contents of destination operand to the left by the
specified count excluding carry
operand CF 1010111000100101
count=1 1 0 101110001001011
Lecture Notes
RCR -Rotate right through carry
This instruction rotates the contents (bitwise) of the destination operand right by the count
through CF. For each operation CF is passed into MSB of the operand & LSB is pushed into
carry flag.
This instruction rotates 16bit the contents of destination operand left by the specified count
through the CF. For each operation, the carry flag is pushed into the LSB & MSB is pushed
into CF.
This instruction is used as a prefix to other instruction. The instruction to which the REP
prefix is provided is executed repeatedly till CX register becomes zero (at each iteration CX
is automatically decremented by 1.
This instruction is used to move a string byte or word from one location (specified
by segment name & source index [SI] ) to another location ( specified by segments
name & destination index DI )
This can be used to compare two strings of bytes or words. I they are equal, ZF is
set.
This instruction scans a string of bytes or words, for an operand byte or word
specified in register AL or AX. The string is pointed to by ES: DI register pair. The
length of the string is stored in CX. The DF collides the made of scanning (auto
incrementing or decrementing). Whenever a match is found, execution stops and ZF
is set. If no match is found ZF is reset.
This LODS loads the AL/AX register by the content of a string pointed to by DS:SI
Register pair
The STOS stores the AL/AX register contents to a location in the string pointed by
ES: DI register pair.
Lecture Notes
Branching Instruction:
The branching or control instructions transfer the flow of the execution of the
program to an address specified in the instruction directly or indirectly. This can be
classified into two types
Conditional Branching
The execution control is transferred to the specified location provided the result of
the prev ious operation satisfies a particular condition otherwise the execution control
is normal flow sequence
Unconditional Branching:
CALL:
This instruction is used to call a subroutine from a main program. The address of the
subroutine may be specified directly or indirectly depending upon the addressing
mode. There are two types of subroutine depending upon whether it is available in
the same segment. ( intra segment) or in another segment (inter segment).
This instruction is used to transfer the control from the subroutine to main program.
Lecture Notes
INTO: Interrupt or overflow:
This instruction is used to transfer the control from the interrupt serv ice routine to
the main program.
LOOP:
This execute the part of the program from label or address specified in the
instruction up to the loop instruction, CX number of times.
An assembler need some hints from the programmer i.e., the required storage for a
particular constant or a variable, logical names of the segment, types of different
routines and modules, end of file etc.
These types of hints are given to the assembler using some predefined alphabetical
strings called assembler directives.
Another type of hint which helps the assembler to assign a particular constant with a
label or initialize particular memory locations or labels with constant is called an
operator.
Lecture Notes
DB: Define Byte:
E.g.: RANKS DB 01H, 02H, 03H, 04H -> directs the assembler to reserve 4 memory
locations for a list named ‘RANKS’ and initialize them with specified values.
E.g.: VALUE DB 50H -> to reserve 50H memory bytes and leave them uninitialized
for the variable named VALUE.
DW: Define Word: to reserve the number of memory words. E.g.: WORDS DW
1234H, 4567H, 78ABH, 304CH
E.g.: WDATA DW 5 DUP (6006H) ->reserves four words and initializes all words with
the value 6006H.
Define Quadword: (DQ): used to reserve 4 words (8-bytes) of memory for the
specified variable and may initialize it with the specified values.
DT: Define Ten bytes: used to reserve 10bytes of memory for the specified
variable.
ASSUME – Assume Logical Segments Name: used to inform the assembler, the
names of the logical segments to be assumed for different segments used in the
program.
E.g.: ASSUME CS:CODE -> directs the assembler that the machine codes are
available in a segment named CODE, and hence the CS register is to be loaded with
the address allotted by the operating system for the label CODE, while loading.
END: End of program: marks the end of the assembly language program.
Lecture Notes
ENDP: End of procedure: to indicate the end of the procedure (subroutine).
...
STAR ENDP
…...
DATA ENDS
…..
MODULE1 ENDS
…..
MODULE2 ENDS
GROUP: Group the Related Segments: used to form logical groups of segments
with similar purpose or type.
LENGTH: Byte Length of a label: used to refer to the length of a data array or a
string.
E.g.: MOV CX, LENGTH ARRAY – Reg. CX is loaded with the value which is the
length of the array.
EVEN: Align on Even Memory address: The assembler, while starting the
assembling procedure of any program initialize a location counter and goes on
updating it, as the assembly proceeds the EVEN directive updates the location
counter to the next even address, if the current location counter contents are not
even and assigns the following routine or variable or constant to that address.
……………………….
FACT ENDP
Lecture Notes
EQU: Equate: Used to assign a label with a value or a symbol.
ADDITION EQU ADD -> assigns another label ‘ADDITION’ with mnemonic ADD
PUBLIC: informs the assembler that the labels, variables constants or procedures
declared PUBLIC may be accessed by other modules.
EXTRN: Extern: informs the assembler that the names, procedure and label
declared after this directive have already been defined as some other assembly
language module.
OFFSET: offset of a label: when the assembler comes across the OFFSET operator
along with a label, it first computes the 16bit displacement (also called as offset) of
the particular label, and replaces the string OFFSET LABEL by the computed
displacement.
ORG: origin: Directs the assembler to stack the memory allotment for the
particular segment, block or code from the declared address in the ORG statement.
SEG: Segment of a label: The SEG operator is used to decide the segment
address of the label, variable or procedure and substitutes the segment base
address in the place of ‘SEG LABEL’.
E.g.: MOV AX, SEG ARRAY -> moves the segment address of ARRAY in which it is
appearing to register AX and then to DS.
…….
CODE ENDS
SHORT: indicates to the assembler that only one byte is required to code the
displacement for a jump.
GLOBAL: The labels, variables, constants or procedures declared GLOBAL may be used by
other modules of the program. Once a variable is declared GLOBAL, it can be used by any
module in the program.
MOV DL,00
MOV AL,[1100]
MOV BL,[1101]
ADD AL,BL
JNC L1
INC DL
MOV [1103],DL
HLT
MOV AL,[1100]
MOV BL,[1101]
Lecture Notes
DIV AL,BL
MOV [1102],AX
HLT
MOV AX,0000
MOV SI,1100
MOV DI,1200
MOV DX,0000
INC SI
INC SI
INC DX
CMP CX, DX
JNZ L1
MOV [1200],AX
HLT
Lecture Notes
ALP for Subtraction of two 16-bit numbers
CODE SEGMENT
SUB AX, BX
JNC L1
MOV [DI+02], CL
INT 3H
CODE ENDS
END START
Lecture Notes
ALP for Multiplication of two 16-bit numbers
CODE SEGMENT
MUL BX
MOV [DI], AX
MOV [DI+02], DX
INT 3H
CODE ENDS
END START
Lecture Notes
ALP for 2’s Complement 16-bit number
CODE SEGMENT
NOT AX
INC AX
MOV [1300], AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
DATA SEGMENT
DATA ENDS
Lecture Notes
CODE SEGMENT
CODE ENDS
END START
Complex programs are div ided into many parts and each sub-part are known as
modules. All the modules perform a well-defined task. Formulation of computer code
using a module is known as modular programming.
Most assembler languages are used in modularization process in three ways such as,
Lecture Notes
1.Allow data to be structured so that they can be accessed by several modules
Stack Operation
Procedures
Interrupt process
The assembly language program can be written with an ordinary text editor such as
word star, editor etc. The assembly language program text is an input to the
assembler. The assembler translates assembly language statements to their binary
equivalent known as object code. During assembling process assembler checks for
syntax errors and displays them before giv ing object code module. The object code
module contains the information about where the program or module to be loaded
in memory. If the object module is to be linked with other separate modules, then it
contains additional linkage information.
At link time, separately assembled modules are combined into one single load
module by the linker. The linker also SUBs any required initialization or finalization
code to allow the OS to start the program running and to return control to OS after
the program is completed.
Lecture Notes
At load time, the program loader copies the program into computer main memory
and at execution time, the program execution begins. If the modules in the program
they are assembled separately, then there is one main module and other modules.
This main module has the first instruction to be executed and it is terminated by an
END statement with entry point satisfied. Other modules are terminated by an END
statement with no operand.
Segment combination
In addition to the linker commands, the assembler prov ides a means of regulating
the way segments in different object modules are organized by the linker. Segments
with same name are joined together by using the modifiers attached to the
SEGMENT directives.
Lecture Notes
SEGMENT directive may have the form
where the combine-type indicates how the segment is to be located within the
load module. Segments that have different names cannot be combined and
segments with the same name but no combine-type will cause a linker error.
PUBLIC – If the segments in different modules have the same name and combine- type
PUBLIC, then they are concatenated into a single element in the load module. The
ordering in the concatenation is specified by the linker command.
COMMON – If the segments in different object modules have the same name and the
combine-type is COMMON, then they are overlaid so that they have the same starting
address. The length of the common segment is that of the longest segment being
overlaid.
STACK – If segments in different object modules have the same name and the combine
type STACK, then they become one segment whose length is the sum of the lengths of
the individually specified segments. In effect, they are combined to form one large stack
MEMORY – This combine-type causes the segment to be placed at the last of the load
module. If more than one segment with the MEMORY combine-type is being linked, only
the first one will be treated as having the MEMORY combine type; the others will be
overlaid as if they had COMMON combine-type.
Lecture Notes
Fig. Segment combinations resulting from the PUBLIC and
Common Combination types
Lecture Notes
Fig. Formation of a stack from two segments
other modules being linked, then it is referred to as an external (or global) identifier
relative to the module. Two lists are implemented by the EXTRN and PUBLIC
directives, which have the forms:
Lecture Notes
EXTRN Identifier: Type …. Identifier: Type
and
where the identifiers are the variables and labels being declared or as being
available to other modules.
The assembler must know the type of all external identifiers before it can generate
the proper machine code, a type specifier must be associated with each identifier in
an EXTRN statement.
For a variable the type may be BYTE, WORD, or DWORD and for a label it may be
NEAR or FAR.
One of the primary tasks of the linker is to verify that every identifier appearing in
an EXTRN statement is matched by one in a PUBLIC statement. If this is not the
case, then there will be an undefined reference and a linker error will occur. The
offsets for the local identifier will be inserted by the assembler, but the offsets for
the external identifiers and all segment addresses must be inserted by the linking
process. The offsets associated with all external references can be assigned once all
of the object modules have been found and their external symbol tables have been
examined.
The assignment of the segment addresses is called relocation and is done after the
linking process has determined exactly where each segment is to be put in memory.
Lecture Notes
1.8 STACKS
The stack is a block of memory that may be used for temporarily storing the
contents of the registers inside the CPU. It is a top-down data structure
whose elements are accessed using the stack pointer (SP) which gets
decremented by two as we store a data word into the stack and gets
incremented by two as we retrieve a data word from the stack back to the
CPU register.
The process of storing the data in the stack is called ‘pushing into’ the stack
and the reverse process of transferring the data back from the stack to the
CPU register is known as ‘popping off’ the stack. The stack is essentially Last-
In-First -Out (LIFO) data segment. This means that the data which is pushed
into the stack last will be on top of stack and will be popped off the stack first.
The stack pointer is a 16-bit register that contains the offset address of the
memory location in the stack segment. The stack segment, like any other
segment, may have a memory block of a maximum of 64 Kbytes locations,
and thus may overlap with any other segments. Stack Segment register (SS)
contains the base address of the stack segment in the memory.
The Stack Segment register (SS) and Stack pointer register (SP) together
address the stack- top as explained below:
SS ===== 5000 H
SP===== 2050 H
Lecture Notes
If the stack top points to a memory location 52050H, it means that the location
52050H is already occupied with the prev iously pushed data. The next 16 bit push
operation will decrement the stack pointer by two, so that it will point to the new
stack-top 5204EH and the decremented contents of SP will be 204EH. This location
will now be occupied by the recently pushed data.
Thus for a selected value of SS, the maximum value of SP=FFFFH and the segment
can have maximum of 64K locations. If the SP starts with an initial value of FFFFH, it
will be decremented by two whenever a 16-bit data is pushed onto the stack. After
successive push operations, when the stack pointer contains 0000H, any attempt to
further push the data to the stack will result in stack overflow.
After a procedure is called using the CALL instruction, the IP is incremented to the
next instruction. Then the contents of IP, CS and flag register are pushed
automatically to the stack. The control is then transferred to the specified
Addressing the CALL instruction i.e. starting Address of the procedure. Then the
procedure is executed.
A procedure is a set of code that can be branched to and returned from in such a
way that the code is as if it were inserted at the point from which it is branched to.
The branch to procedure is referred to as the call, and the corresponding branch
back is known as the return. The return is always made to the instruction
immediately following the call regardless of where the call is located.
The CALL instruction not only branches to the indicated address, but also pushes the
Return Address onto the stack. The RET instruction simply pops the return Address
from the stack. The registers used by the procedure need to be stored before their
contents are changed, and then restored just before their contents are changed, and
then restored just before the procedure is excited.
Procedures are used in the source code by placing a statement of the form at the
beginning of the procedure
--------
----------
Procedure or subroutine may require input data or constants for their execution.
Their data or constants may be passed to the subroutine by main program or some
subroutine may access readily available data of constants available in memory.
Generally, the following technique are used to pass input / parameter to procedures
in ALP
d) Using stack
A variable or a parameter label may be declared global in the main program and the
same variable or parameter label can be used by all the procedures of the
application.
DATA SEGMENT
DATA ENDS
CODE1 SEGMENT
MOV DS,AX
--
CODE1 ENDS
CODE2 SEGMENT
MOV DS, AX
--
CODE2 ENDS
END START
Lecture Notes
b) Using registers of CPU architecture
The CPU general purpose registers may be used to pass parameters to the
procedures. The main program may store the parameters to be passed to the
procedure in the variable CPU registers and the procedure may use the same
register content for execution. The original content of the used CPU register may
change during execution of the procedure. This may be avoided by pushing all the
register content to be used to the stack sequentially at the start of the procedure
and popping all the register contents at the end of the procedure in opposite
sequence.
CODE SEGMENT
MOV BX , 5456H
--
PROCEDURE P1 NEAR
--
ADD AX , BX
--
RET
P1 ENDP
CODE ENDS
END START
Lecture Notes
c)Using memory location
Memory location may also be used to pass parameter to a procedure in the same
way as registers. A main program may store the parameter to be passed to a
procedure at known memory address location and the procedure may use the same
location for accessing the parameter.
Example:
DATA SEGMENT
NUM DB (55H)
DATA ENDS
CODE SEGMENT
MOV DS,AX
--
CALL ROUTINE
--
MOV BX , NUM
MOV CX , COUNT
--
Lecture Notes
ROUTINE ENDP
CODE ENDS
END START
d)Using stack
Stack memory can also be used to pass parameters to procedure. A main program
may store the parameters to be passed to a procedure in its CPU registers. The
registers will further be pushed on to the stack. The procedure during its execution
pops back the appropriate parameters as and when required. This procedure of
popping back the parameters must be implemented carefully because besides the
parameters to be passed to the procedure the stack contains other important
information like contents of other pushed registers, return addresses from the
current procedure and other procedure or interrupt service routines.
Example:
STACK SEGMENT
STACK ENDS
CODE SEGMENT
MOV SS,AX
Lecture Notes
MOV BX , 55H
MOV CX , 10H
--
PUSH AX
PUSH CX
CALL ROUTINE
--
--
MOV DX , SP
ADD SP ,02H
POP CX
POP BX
MOV SP , DX
--
ROUTINE ENDP
CODE ENDS
END START
Lecture Notes
e)Using PUBLIC and EXTERN
For passing the parameters to procedures using the PUBLIC & EXTERN directives , must be
declared PUBLIC (for all routine) in the main routine and the same should be declared
EXTERN in the procedure Thus the main program can pass the PUBLIC parameter to a
procedure in which it is declared EXTERN(external)
Example:
DATA SEGMENT
DATA ENDS
CODE SEGMENT
MOV DS, AX
--
CALL ROUTINE
--
EXTERN NUMBER
MOV AX , NUMBER
--
Lecture Notes
ROUTINE ENDP
CODE ENDS
END START
1.10 MACROS:
Suppose, a number of instructions are appearing again and again in the main
program, the listings become lengthy. So a macro definition i.e., a label, is assigned
with the repeatedly appearing string of instructions. The process of assigning a label
or macro name to the string is called defining a macro. A macro within a macro is
called a nested macro.
The difference between a macro and a subroutine is that, in case of macro the
complete code of instructions string is inserted at each place where the macro-name
appears. Hence the EXE file becomes lengthy. There is no question of transfer of
control as the program using the macro inserts the complete code of the macro at
every reference of the macro-name.
on the other hand, subroutine is called whenever necessary, i.e. the control of
execution is transferred to the subroutine, every time it is called. The executable
code in case of the subroutines becomes smaller as the subroutine appears only
once in the complete code. The control is transferred to a subroutine whenever it is
called, and this utilizes the stack service. The program using subroutine requires less
memory space for execution that that using macro. Macro, requires less time for
execution, as it does not contain CALL and RET instructions as the subroutines do.
Lecture Notes
Defining a MACRO:
A macro can be defined anywhere in a program using the directives MACRO and
ENDM. The label prior to MACRO is the macro-name which should be used in the
actual program. The ENDM directive marks the end of the instructions or statements
sequence assigned with the macro name. The following macro DISPLAY displays the
message MSG on the CRT. The syntax is as given.
DISPLAY MACRO
MOV DS, AX
INT 21H
ENDM
The above definition of a macro assigns the name DISPLAY to the instruction
sequence between the directives MACRO and ENDM. While assembling, the above
sequence of instructions will replace the label ‘DISPLAY’, whenever it appears in the
program.
A macro may also be used in a data segment. In other words, a macro may be used
to represent statements and directives. The concept of macro remains the same
independent of its contents.
Lecture Notes
E.g.:
STRINGS MACRO
ENDM
A macro may be called by quoting its name, along with any values to be passed to
the macro.
DISPLAY MACRO
MOV DS, AX
INT 21H
ENDM
Lecture Notes
This parameter MSG can be replaced by MSG1 or MSG2 while calling the MACRO as
shown.
CODE SEGMENT
……..
DISPLAY MSG1
…...
DISPLAY MSG2
………
CODE ENDS
END START
There may be more than one parameter appearing in the macro definition, meaning
thereby that there may be more than one parameters to be passed to the macro,
and each of them is liable to be changed. All the parameters are specified in the
definition sequentially and
Lecture Notes
also in the call with the same sequence. A macro may be defined in another macro or in
other words a macro may be called from inside a macro. This is called nested macro.
(For example, in 8086 processor, div ide by zero is an exceptional condition which
initiates type 0 interrupt and such an interrupt is also called execution). The process
of interrupting the normal program execution to carry out a specific task/work is
referred to as interrupt. The interrupt is initiated by a signal generated by an
external device or by a signal generated internal to the processor.
Lecture Notes
When a microprocessor receives an interrupt signal it stops executing current
normal program, save the status (or content) of various registers (IP, CS and flag
registers in case of 8086) in stack and then the processor executes a
subroutine/procedure in order to perform the specific task/work requested by the
interrupt. The subroutine/procedure that is executed in response to an interrupt is
also called Interrupt Serv ice Subroutine (ISR). At the end of ISR, the stored status
of registers in stack is restored to respective registers, and the processor resumes
the normal program execution from the point {instruction) where it was interrupted.
The external interrupts are used to implement interrupt driven data transfer scheme.
The interrupts generated by special instructions are called software interrupts and
they are used to implement system services/calls (or monitor serv ices/calls). The
system/monitor services are procedures developed by system designer for various
operations and stored in memory. The user can call these services through software
interrupts. The interrupts generated by exceptional conditions are used to
implement error conditions in the system.
Interrupt Driven Data Transfer Scheme The interrupts are useful for efficient data
transfer between processor and peripheral. When a peripheral is ready for data
transfer, it interrupts the processor by sending an appropriate signal. Upon receiv ing
an interrupt signal, the processor suspends the current program execution, save the
status in stack and executes an ISR to perform the data transfer between the
peripheral and processor.
At the end of ISR the processor status is restored from stack and processor resume
its normal program execution. This type of data transfer scheme is called interrupt
driven data transfer scheme.
The data transfer between the processor and peripheral dev ices can be implemented
either by polling technique or by interrupt method. In polling technique, the
processor has to periodically poll or check the status/readiness of the device and can
perform data transfer only when the device 'is ready. In polling technique, the
processor time is wasted, because the processor has to suspend its work and check
the status of the device in predefined intervals.
Lecture Notes
If the device interrupts the processor to initiate a data transfer whenever it is ready,
then the processor time is effectively utilized because the processor need not
suspend its work and check the status of the device in predefined intervals.
For an example, consider the data transfer from a keyboard to the processor.
Normally a keyboard has to be checked by the processor once in every 10
milliseconds for a key press. Therefore, once in every 10 milliseconds the processor
has to suspend its work and then check the keyboard for a valid key code.
Alternatively, the keyboard can interrupt the processor, whenever a key is pressed
and a valid key code is generated. In this way the processor need not waste its time
to check the keyboard once in every 10 milliseconds.
Classification of Interrupts
The interrupts initiated by applying appropriate signal to these pins are called
hardware interrupts of 8086.
The software interrupts are program instructions. These instructions are inserted at
desired locations in a program. While running a program, if software interrupt
instruction is encountered then the processor initiates an interrupt. The 8086 processor has
256 types of software interrupts. The software interrupt instruction is INT n, where n is the
type number in the range 0 to 255.
Lecture Notes
When an interrupt signal is accepted by the processor, if the program control
automatically branches to a specific Address (called vector Address) then the
interrupt is called vectored interrupt.
All the 8086 interrupts are vectored interrupts. The vector Address for an 8086
interrupt is obtained from a vector table implemented in the first 1kb memory space
(00000h to 03FFFh).
The processor has the facility for accepting or rejecting hardware interrupts.
Programming the processor to reject an interrupt is referred to as masking or
disabling and programming the processor to accept an interrupt is referred to as
unmasking or enabling. In 8086 the interrupt flag (IF) can be set to one to unmask
or enable all hardware interrupts and IF is cleared to zero to mask or disable a
hardware interrupts except NMI.
The interrupts whose request can be either accepted or rejected by the processor
are called maskable interrupts. The interrupts whose request has to be definitely
accepted (or cannot be
An interrupt in 8086 can come from one of the following three sources.
Lecture Notes
1. One source is from an external signal applied to NMI or INTR input pin of the
processor. The interrupts initiated by apply ing appropriate signals to these input pins
are called hardware interrupts.
3. The third source of an interrupt is from some condition produced in the 8086 by
the execution of an instruction. An example of this type of interrupt is divide by zero
interrupt. Program execution will be automatically interrupted if you attempt to
divide an operand by zero. Such conditional interrupts are also known as exceptions.
Interrupts of 8086
The 8086 microprocessor has 256 types of interrupts. INTEL has assigned a type
number to each interrupt. The type numbers are in the range of 0 to 255. The 8086
processor has dual facility of initiating these 256 interrupts. The interrupts can be
initiated either by executing "INT n" instruction where n is the type number or the
interrupt can be initiated by sending an appropriate signal to INTR input pin of the
processor.
3.Software Interrupts
4.Internal Interrupts
5.Reset
Interrupts Priority
Each interrupt is given a different priority level by assigning a type number. Type 0
identifies highest priority and type 255 identifies the lowest priority interrupt.
Lecture Notes
The interrupt priority follows,
Reset
Internal interrupts
Software interrupts
The first 1Kbyte of memory of 8086 (00000 to003FF) is set aside as a table for
storing the starting addresses of Interrupt Service Procedures(ISP). Since 4-bytes
are required for storing starting addresses of ISPs, the table can hold 256 Interrupt
procedures.
The starting Address of an ISP is often called the Interrupt Vector or Interrupt
Pointer. Therefore, the table is referred as Interrupt Vector Table. In this table, IP
value is put in as low word of the vector & CS is put in high vector.
1.External interface sends an interrupt signal, to the Interrupt Request (INTR) pin,
or an internal interrupt occurs.
2.The CPU finishes the present instruction and sends Interrupt Acknowledge (INTA)
to hardware interface.
3. The interrupt type N is sent to the Central Processing Unit (CPU) v ia the data bus
from hardware interface.
4. The contents of the flag registers are pushed onto the stack.
Lecture Notes
5. Both interrupts (IF) and (TF) flags are cleared. This disables the INTR pin and the
trap or single step feature.
6. The contents of the code segment register (CS) are pushed onto the stack.
7. The contents of the instruction pointer (IP) are pushed onto the stack.
8. The interrupt vector contents are fetched, from(4*N) and then placed into the IP
and from(4*N+2) into the CS so that the next instruction executes at the interrupt
service procedure addressed by the interrupt vector.
9.While returning from the interrupt service routine by the Interrupt return (IRET)
instruction, The IP, CS and Flag registers are popped from the stack and return their
state prior to the interrupt.
Other examples are to compare the elements and two strings together in order to
determine whether they are the same or different.
An element of the string specified by the source index (SI) register with respect to
the current data segment (DS) register is moved to the location specified by the
destination index (DI) register with respect to the current extra segment (ES)
register. The move can be performed on a byte (MOVSB) or a word (MOVSW) of
data. After the move is complete, the contents of both SI & DI are automatically
incremented or decremented by 1 for a byte move and by 2 for a word move.
Address pointers SI and DI increment or decrement depends on how the direction
flag DF is set.
LODSB: Loads a byte from a string in memory into AL. The Addressing SI is used
relative to DS to determine the Address of the memory location of the string
element.
[SI] = [SI] + 1
LODSW: The word string element at the physical Address derived from DS and SI is
to be loaded into AX. SI is automatically incremented by 2.
Lecture Notes
AX = [(DS) + (SI)]
[SI] = [SI] + 2
STOSB:
Stores a byte from AL into a string location in memory. This time the contents of ES
and DI are used to form the Address of the storage location in memory.
[ES + DI] = AL
DI = DI + 1
STOSW:
[ES + DI] = AX
DI = DI + 2
The basic string operations must be repeated to process arrays of data. This is done
by inserting a repeat prefix before the instruction that is to be repeated. Prefix REP
causes the basic string operation to be repeated until the contents of register CX
become equal to zero. Each time the instruction is executed, it causes CX to be
tested for zero, if CX is found to be nonzero it is decremented by 1 and the basic
string operation is repeated.
Example:
STOSB
MOV AX, 0
MOV ES, AX
MOV AX, 0
MOV ES, AX
REP STOSB
The prefixes REPE and REPZ stand for same function. They are meant for use with
the CMPS and SCAS instructions. With REPE/REPZ the basic compare or scan
operation can be repeated as long as both the contents of CX are not equal to zero
and zero flag is 1.
REPNE and REPNZ works similarly to REPE/REPZ except that now the operation is
repeated as long as CX ≠ 0 and ZF=0. Comparison or scanning is to be performed
as long as the string elements are unequal (ZF=0) and the end of the string is not
yet found (CX ≠ 0).
When CLD (Clear Direction Flag) is executed DF=0 permits auto increment by 1.
When STD (Set Direction Flag) is executed DF=1 permits auto decrement by 1.
Lecture Notes - Links to Videos
https://drive.google.com/file/d/18SGrGgu1EoUOvuntxPbAI0Lttu9wfLC
H/view?usp=sharing
https://drive.google.com/file/d/19yRuBkcB4Yx2tSavyBIUYTF_yW1ma
UOv/view?usp=sharing
https://drive.google.com/file/d/1EzEHcBZFHb6gDzskrsQe8ZCb70ax0U
E4/view?usp=sharing
https://drive.google.com/file/d/1jizz79YcBuMx227TohdzbzPh12VsNzZ
G/view?usp=sharing
Link:
https://drive.google.com/file/d/1O3H8WHOIyGKqsjTItS-
gySXsymqzDgqx/view?usp=sharing
Lecture Notes - PPTs
https://drive.google.com/file/d/1wwogZRYhYoVR6t69VQCG5HiMbRld4
p4p/view?usp=sharing
https://drive.google.com/file/d/1pSb4ovcYLcUJuXmjsHQb2_qMnHzhB0
ms/view?usp=sharing
Lecture Notes – Quiz
Link for Quiz1
https://docs.google.com/forms/d/e/1FAIpQLSfWFiJfXfjIm5bFEY9oqZd
3aRuGqFvkt9P08hDpffIvJ0NZ9g/viewform?usp=pp_url
https://docs.google.com/forms/d/111ETwQubkFlfssQCUCO-
ecW9vimirrqRD2QRiuNjcgU/edit?usp=sharing
Lecture Notes – References
NPTEL Lecture Materials References
Link: http://nptel.ac.in/courses/108107029/
link: http://nptel.ac.in/courses/106108100/
Assignments
Write a 8086 Assembly Language Program to convert ASCII to Binary &
vice versa and Hexa Decimal to Decimal & vice versa with detailed
during execution and sort the inputs then display the result in the
its with its number notations and how it is called by INT 21H instruction.
28. What is the similarity and difference between subtract and compare
instructions? K2 – CO1
Similarity : Both the subtraction and comparison are performed by subtracting two
data in ALU and flags are altered depending upon the result.
34. The offset address of a data is 341BH and the data segment register
value is 123AH . What is the physical address of the data? K3-CO1
Segment Address shifted by 4 bits towards left = 123A0H
Offset Address is = 341BH
20 bit Physical Address = 157BBH
Part B Qs (with K level and CO)
1. Explain the features of 8086 microprocessor. (8) - K1 - CO1
4. Explain the architecture of 8086 processor with the help of neat block diagram.
(13) – K1 - CO1
7. Give three examples for the following 8086 microprocessor instructions: String,
Processor Control, Program execution transfer instructions and bit manipulation
instructions. (13) – K2 - CO1
8. Briefly explain instruction set of 8086 in detail with examples. (13). – K1 - CO1
9. Give an example for the 8086 instructions: AAA, CWD, JNBE, LAHF, MOVS, RCL,
ROL and SAHF.(8) – K2 - CO1
10. Explain the following assembler directives in detail: 1) ASSUME 2) EQU 3)DD
4)DW (8) – K1 - CO1
11. What are assembler directives and Give examples with explanation.(13) – K1 -
CO1
12. Explain the following assembler directives DD,ENDS, EVEN & EXTRN (8) – K1 -
CO1
13. Explain the following assembler directives. SHORT, TYPE, FAR (3) – K1 - CO1
14. Explain the steps of Linking and Relocation of a program during execution in
detail. – K1 - CO1
Part B Qs (with K level and CO)
15. Explain the detail the stack structure of 8086. Write a simple program to
illustrate the concept of programming the stack. – K3 - CO1
19. Write an assembly language program in 8086 to search the largest data in an
array.(13) – K3 - CO1
21. Write short notes on interrupts, the sequence of steps during the interrupt and
interrupt service routines.(8) – K1 - CO1
22. Explain the interrupt structure of an 8086 microprocessor with its interrupt
vector table with its types.(8) – K1 - CO1
23. Write a program to multiply 2 digit numbers by getting an input from the
keyboard using BIOS interrupt call. (13) – K3 - CO1
24. Write an 8086 ALP to get an input from the keyboard for 2 digits and convert
that input into hexa decimal number using BIOS int. (13) – K3 – CO1
25. Explain how instruction pipeline works in 8086 and mention how it helps in
improving CPU’s performance. (8) – K4 – CO1
26. Distinguish between the following pairs: NEAR and FAR procedures, macros
and subroutines. (8) – K3 – CO1
28. Write a 8086 ALP to convert BCD Data to Binary Data. (13) – K3 – CO1
Part B Qs (with K level and CO)
29. Write an 8086 program that checks whether a multi-byte number that satisfies
even parity or not. (4) – K4 – CO1
30. Write an 8086 assembly language program using string primitives to find out
whether a given name is present in a list of names. (8) – K3 – CO1
31. Explain how BIOS function calls are invoked in assembly language programs. (8)
– K2 – CO1
Supportive online Certification
courses
NPTEL:
https://nptel.ac.in/courses/106/108/106108100/
Udemy:
https://www.udemy.com/course/8086-microprocessor-
architecture-in-one-video-in-easy-way/
https://www.udemy.com/course/certificate-program-in-
introduction-to-microprocessors/
Real time Applications in day to day
life and to Industry
Gaming devices.
Digital Clocks.
Scientific Calculators
Microcomputers
Contents beyond the Syllabus
https://drive.google.com/file/d/1m94L4FebpyTmpTuc6pOyMOBivmulLj
NR/view?usp=sharing
Lecture Notes - Links to Videos
https://drive.google.com/file/d/1LsDFrvRDC60oY7HmW9ijVX9ef2mdRpO
9/view?usp=sharing
https://www.youtube.com/watch?v=yXahWYYNPXE
https://www.youtube.com/watch?v=cNN_tTXABUA&t=349s
Lecture Notes - e-book reference
Link:
https://drive.google.com/file/d/1O3H8WHOIyGKqsjTItS-
gySXsymqzDgqx/view?usp=sharing
Lecture Notes - PPTs
https://drive.google.com/file/d/1efGPi2H--
Qv76RUy3SUvOFSETNIyNGEp/view?usp=sharing
https://drive.google.com/file/d/1LLuzfxqn1BCaKMM-zhh-
czDN7ykVZ80-/view?usp=sharing
Lecture Notes – Quiz
https://docs.google.com/forms/d/1j-
IEljj7YeVaJbzUo9LRVwsOdKjKsNrdPQdrvupl2F8/edit?usp=sharing
https://docs.google.com/forms/d/e/1FAIpQLSd3UI834dCNwct00fBfhH
_Ft82Gz57H81wZqHI_1S8KJR3bww/viewform?usp=pp_url
Assignments
Write a procedure to calculate the volume of a sphere using MASM.
(Hint. Use 8087 instructions along with 8086 instructions)
https://nptel.ac.in/courses/108/103/108103157/
https://nptel.ac.in/courses/117/104/117104072/
UDEMY:
https://www.udemy.com/course/learn-js-easily/
Real time Applications in day to day
life and to Industry
3D graphics with audio/video compression.
Gaming devices.
Digital Clocks.
Scientific Calculators
Microcomputers
Contents beyond the Syllabus
https://drive.google.com/file/d/1m94L4FebpyTmpTuc6pOyMOBivmulLj
NR/view?usp=sharing
Assessment Schedule
Assessment I
Mohamed Ali Mazidi, Janice Gillispie Mazidi, Rolin McKinlay, ―”The 8051
Microcontroller and Embedded Systems: Using Assembly and C”, Second
Edition, Pearson education, 2011. (UNIT IV-V).
REFERENCES:
Disclaimer:
This document is confidential and intended solely for the educational purpose of RMK Group
of Educational Institutions. If you have received this document through email in error,
please notify the system manager. This document contains proprietary information and is
intended only to the respective group / learning community as intended. If you are not the
addressee you should not disseminate, distribute or copy through e-mail. Please notify the
sender immediately by e-mail if you have received this document by mistake and delete this
document from your system. If you are not the intended recipient you are notified that
disclosing, copying, distributing or taking any action in reliance on the contents of this
information is strictly prohibited.