0% found this document useful (0 votes)
5 views27 pages

Unit 1 MPMC Notes

The document provides an overview of the 8086 microprocessor, detailing its architecture, components, and functionalities, including the CPU, memory, and I/O systems. It explains the roles of the Bus Interface Unit and Execution Unit, as well as the various registers and addressing modes used in the 8086 microprocessor. Additionally, it outlines the historical development of microprocessors and highlights the features and capabilities of the 8086 microprocessor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views27 pages

Unit 1 MPMC Notes

The document provides an overview of the 8086 microprocessor, detailing its architecture, components, and functionalities, including the CPU, memory, and I/O systems. It explains the roles of the Bus Interface Unit and Execution Unit, as well as the various registers and addressing modes used in the 8086 microprocessor. Additionally, it outlines the historical development of microprocessors and highlights the features and capabilities of the 8086 microprocessor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT

UNIT-I
THE 8086 MICROPROCESSOR

INTRODUCTION TO MICROPROCESSOR:
OVERVIEW OF A SIMPLE MICRO COMPUTER:

The major parts are the central processing unit or CPU, memory, and the input and output circuitry or I/O.
Connecting these parts together are three sets of parallel lines called buses. The three buses are the address
bus, the data bus, and the control bus.

Block diagram of simple computer or microcomputer.

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

1
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
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 devices. 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.
What is a Microprocessor?
• The word comes from the combination micro and processor.
– Processor means a device that processes numbers, specifically binary numbers, 0’s and 1’s.
– Micro is a new addition.
– In the late 1960’s, processors were built using discrete elements.
– These devices performed the required operation, but were too large and too slow.
– In the early 1970’s the microchip was invented. All of the components that made up the
processor were now placed on a single piece of silicon. The size became several thousand
times smaller and the speed became several hundred times faster.
– The “Micro” Processor was born.
Definition of Microprocessor:
 Microprocessor is a multipurpose, programmable device that accepts digital data as input, processes
it according to instructions stored in its memory, and provides results as output.
or

 A microprocessor is a multipurpose, programmable, clock-driven, register-based electronic device


that reads binary instructions from a storage device called memory accepts binary data as input and
processes data according to instructions, and provides result as output.

2
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
MICROCONTROLLER:
 A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated
circuit containing a processor core, memory, and programmable input/output peripherals.

or

 CPUs with integrated memory or peripheral interfaces

History of Microprocessors:

Processor No. of Clock speed Year of


bits (Hz) introduction
4004 4 740K 1971
8008 8 500K 1972

8080 8 2M 1974
8085 8 3M 1976
8086 16 5, 8 or 10M 1978
8088 16 5, 8 or 10M 1979
80186 16 6M 1982
80286 16 8M 1982
80386 32 16 to 33M 1986
80486 32 16 to 100M 1989
Pentium 32 66M 1993
Pentium II 32 233 to 500M 1997
Pentium III 32 500M to 1.4G 1999
Pentium IV 32 1.3 to 3.8G 2000
Dual core 32 1.2 to 3 G 2006
Core 2 Duo 64 1.2 to 3G 2006
i3, i5 and i7 64 2.4G to 3.6G 2010

3
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT

8086 Microprocessor features:


 It is 16-bit microprocessor
 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.
 It has 20 bit address bus and can access up to 220 memory locations (1 MB).
 It can support up to 64K I/O ports
 It provides 14, 16-bit registers
 It has multiplexed address and data bus AD0-AD15 & A16-A19
 It requires single phase clock with 33% duty cycle to provide internal timing.
 Prefetches up to 6 instruction bytes from memory and queues them in order to speed up the
processing.
 It is available in 3 versions based on the frequency of operation –

o 8086 → 5MHz
o 8086-2 → 8MHz
o 8086-1 → 10 MHz
 8086 supports 2 modes of operation
 Minimum mode
 Maximum mode

4
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT

Architecture of 8086 microprocessor:


 As shown in the below figure, the 8086 CPU is divided into two independent functional parts
o Bus Interface Unit(BIU)

o Execution Unit(EU)

 Dividing the work between these two units’ speeds up processing.

5
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
The Execution Unit (EU):
 Execution unit gives instructions to BIU stating from where to fetch the data and then decode
and execute those instructions.
 Its function is to control operations on data using the instruction decoder & ALU.
 EU has no direct connection with system buses as shown in the above figure, it performs
operations over data through BIU.
 The EU contains control circuitry, which directs internal operations.
 The main functions of EU are:
o Decoding of Instructions

o Execution of instructions
ALU:

 The EU has a 16-bit arithmetic logic unit (ALU) which can add, subtract, AND, OR, XOR,
increment, decrement, complement or shift binary numbers.

Flag Register:

 It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status according to the
result stored in the accumulator.
 It has 9 flags and they are divided into 2 groups
o Conditional Flags
o Control Flags

Conditional Flags

 It represents the result of the last arithmetic or logical instruction executed. Following is
the list of conditional flags –

 Carry flag − This flag indicates an overflow condition for arithmetic operations.

 Auxiliary flag − When an operation is performed at ALU, it results in a carry/barrow from lower nibble
(i.e. D0 – D3) to upper nibble (i.e. D4 – D7), then this flag is set, i.e. carry given by D3 bit to D4 is AF flag.
The processor uses this flag to perform binary to BCD conversion.

6
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 Parity flag − This flag is used to indicate the parity of the result, i.e. when the lower order 8-bits of the
result contains even number of 1’s, then the Parity Flag is set. For odd number of 1’s, the Parity Flag is
reset.

 Zero flag − This flag is set to 1 when the result of arithmetic or logical operation is zero else it is set to
0.

 Sign flag − This flag holds the sign of the result, i.e. when the result of the operation is negative, then
the sign flag is set to 1 else set to 0.

 Overflow flag − This flag represents the result when the system capacity is exceeded.

Control Flags

 Control flags controls the operations of the execution unit. Following is the list of control
flags –

 Trap flag − It is used for single step control and allows the user to execute one instruction at a time for
debugging. If it is set, then the program can be run in a single step mode.

 Interrupt flag − It is an interrupt enable/disable flag, i.e. used to allow/prohibit the interruption of a
program. It is set to 1 for interrupt enabled condition and set to 0 for interrupt disabled condition.

 Direction flag − It is used in string operation. As the name suggests when it is set then string bytes are
accessed from the higher memory address to the lower memory address and vice-a-versa.

General purpose register

 There are 8 general purpose registers, i.e., AH, AL, BH, BL, CH, CL, DH, and DL.
 These registers can be used individually to store 8-bit data and can be used in pairs to
store 16 bit data.
 The valid register pairs are AH and AL, BH and BL, CH and CL, and DH and DL. It is referred
to the AX, BX, CX, and DX respectively.

 AX register − It is also known as accumulator register. It is used to store operands for arithmetic
operations.

 BX register − It is used as a base register. It is used to store the starting base address of the memory
area within the data segment.

 CX register − It is referred to as counter. It is used in loop instruction to store the loop counter.

7
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 DX register − This register is used to hold I/O port address for I/O instruction. Stack pointer register It is
a 16-bit register, which holds the address from the start of the segment to the memory location, where a
word was most recently stored on the stack.

Pointers and Index Registers

 The index and pointer registers are given below:


o BP—Base pointer
o SP—Stack pointer
o SI—Source index
o DI—Destination index
 The pointers registers contain offset within the particular segments.
 The pointer register SP contains offset within the stack segment.
 The pointer register BP contains offset within the data segment.
 The index registers are used as general purpose registers as well as for offset storage in
case of indexed, base indexed and relative base indexed addressing modes.
 The register SI is used to store the offset of source data in data segment.
 The register DI is used to store the offset of destination in data or extra segment.
 The index registers are particularly useful for string manipulation.

Bus Interface Unit (BIU):

 The BIU sends out addresses, fetches instructions from memory, reads data from ports
and memory, and writes data to ports and memory.
 In simple words, the BIU handles all transfers of data and addresses on the buses for the
execution unit.

Instruction queue
 BIU contains the instruction queue. BIU gets upto 6 bytes of next instructions and stores them
in the instruction queue. When EU xecutes instructions and is ready for its next instruction,
then it simply reads the instruction from this instruction queue resulting in increased
execution speed.
 Fetching the next instruction while the current instruction executes is called pipelining.

8
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
Segment Registers:

 There are 4 segment registers. They are:


o Code Segment Register(CS)
o Data Segment Register(DS)
o Extra Segment Register(ES)
o Stack Segment Register(SS)
 The 8086 architecture uses the concept of segmented memory. 8086 able to address a
memory capacity of 1 megabyte and it is byte organized. This 1 megabyte memory is divided
into 16 logical segments. Each segment contains 64 kbytes of memory.
Code segment register (CS): is used for addressing memory location in the code segment of the memory,
where the executable program is stored.
Data segment register (DS): points to the data segment of the memory where the data is stored.
Extra Segment Register (ES): also refers to a segment in the memory which is another data segment in the
memory. Stack Segment Register (SS): is used for addressing stack segment of the memory. The stack
segment is that segment of memory which is used to store stack data.
 While addressing any location in the memory bank, the physical address is calculated from
two parts:
Physical address= segment address + offset address
 The first is segment address, the segment registers contain 16-bit segment base addresses,
related to different segment.
 The second part is the offset value in that segment.

Instruction pointer(IP)
 It store memory location of next instruction to be executed.
Addressing modes of 8086:
 Addressing mode indicates a way of locating data or operands.
 The addressing modes describe the types of operands and the way they are accessed for executing an
instruction.
1. Immediate: In this type of addressing, immediate data is a part of instruction and appears in the
form of successive byte or bytes.
Ex: MOV AX, 0005H
In the above example, 0005H is the immediate data. The immediate data may be 8-bit or 16-bit in
size.

9
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
2. Direct: In the direct addressing mode a 16-bit memory address (offset) is directly specified in the
instruction as a part of it.
Ex: MOV AX, [5000H]
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.

3. Register: In register addressing mode, the data is stored in a register and is referred using the
particular register. All the registers, except IP, may be used in this mode.
Ex: MOV BX, AX

4. 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. 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.
Ex: MOV AX, [BX]
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.
Ex: MOV AX, [SI]
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].

6. Register Relative: In this addressing mode, the data is available at an effective address formed by
adding an 8-bit or 16-bit displacement with the content of any one of the registers BX, BP, SI and
DI in the default (either DS or ES) segment.
Ex: MOV AX, 50H[BX]
Here, the effective address is given as 10H *DS+50H+[BX]

10
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
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.
Ex: MOV AX, [BX][SI]
Here, BX is the base register and SI is the index register the effective address is computed as 10H
* DS + [BX] + [SI].

8. Relative Based Indexed: The effective address is formed by adding an 8 or 16-bit displacement
with the sum of the contents of any one of the base register (BX or BP) and any one of the index
register, in a default segment.
Ex: MOV AX, 50H [BX] [SI]
Here, 50H is an immediate displacement, BX is base register and SI is an index register the
effective address of data is computed as 10H * DS + [BX] + [SI]

Instruction set of 8086:

The 8086 instructions are categorized into the following main types.

o Data Transfer Instructions


o Arithmetic Instructions
o Bit Manipulation Instructions String Instructions
o Program Execution Transfer Instructions (Branch & Loop Instructions)
o Processor Control Instructions
o Iteration Control Instructions
o Machine control Instructions

11
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
Data Transfer Instructions:

These instructions are used to transfer the data from the source operand to the destination
operand. Following are the list of instructions under this group −

Instruction to transfer a word

 MOV − Used to copy the byte or word from the provided source to the provided destination. The
destination can be a register or a memory location. The source can be a register, a memory location, or an
immediate number.

Syntax: MOV destination, source

Eg: MOV CX, 037AH

 PUSH − Used to put a word at the top of the stack.

Syntax: PUSH Source

Eg: PUSH BX

 POP − Used to get a word from the top of the stack to the provided location.

Syntax: POP Destination

Eg: POP AX

 XCHG − Used to exchange the data from two locations.

Syntax: XCHG Destination, Source

Eg: XCHG BL, CH

 XLAT − Used to translate a byte in AL using a table in the memory.

Eg. LEA BX, TABLE1


MOV AL, 04H
XLAT
Instructions for input and output port transfer

 IN − Used to read a byte or word from the provided port to the accumulator.

Syntax: IN Accumulator, Port Address

Eg: IN AX, 0028 H

12
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 OUT − Used to send out a byte or word from the accumulator to the provided port.

Syntax: OUT Port Address, Accumulator

Eg: OUT 0028 H, AX

Instructions to transfer the address

 LEA − Used to load the address of operand into the provided register.

Syntax: LEA Register, Source

Eg: LEA BX, [DI]

 LDS − Used to load DS register and other provided register from the memory.

Syntax: LDS Register, Memory address of the first word

Eg: LDS BX, [0301 H]

 LES − Used to load ES register and other provided register from the memory.

Syntax: LES Register, Memory address of the first word

Eg: LES BX, [789AH]

Instructions to transfer flag registers

 LAHF − Used to load AH with the low byte of the flag register.

 SAHF − Used to store AH register to low byte of the flag register.

 PUSHF − Used to copy the flag register at the top of the stack.

 POPF − Used to copy a word at the top of the stack to the flag register.

13
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
Arithmetic Instructions

These instructions are used to perform arithmetic operations like addition, subtraction,
multiplication, division, etc.

Instructions to perform addition

 ADD − Used to add the provided byte to byte/word to word. It effects AF, CF, OF, PF, SF, ZF flags.

Syntax: ADD Destination, Source

Eg: ADD DX, AX

 ADC − Used to add with carry. It effects AF, CF, OF, PF, SF, ZF flags.

Syntax: ADC Destination, Source

Eg: ADC DX, AX

 INC − Used to increment the provided byte/word by 1. It effects AF, OF, PF, SF, ZF flags.

Syntax: INC Destination

Eg: INC AX

 AAA (ASCII ADJUST FOR ADDITION) − Used to adjust ASCII after addition.

 DAA (DECIMAL ADJUST AFTER BCD ADDITION) − Used to adjust the decimal after the addition/subtraction
operation.

Instructions to perform subtraction

 SUB − Used to subtract the byte from byte/word from word.

Syntax: SUB Destination, Source

Eg: SUB CX, BX

 SBB − Used to perform subtraction with borrow.

Syntax: SBB Destination, Source

Eg: SBB CH, AL

14
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 DEC − Used to decrement the provided byte/word by 1.

Syntax: DEC Destination

Eg: DEC CL

 NEG − Used to negate each bit of the provided byte/word and add 1/2’s complement.

Eg: NEG AL

 CMP − Used to compare 2 provided byte/word.

Syntax: CMP Destination, Source

 AAS (ASCII ADJUST FOR SUBTRACTION) − Used to adjust ASCII codes after subtraction.

 DAS (DECIMAL ADJUST AFTER BCD SUBTRACTION) − Used to adjust decimal after subtraction.

Instruction to perform multiplication

 MUL − This instruction multiplies an unsigned byte in some source with an unsigned byte in AL register or
an unsigned word in some source with an unsigned word in AX register.

Syntax: MUL Source

Eg: MUL BH

 IMUL − This instruction multiplies a signed byte from source with a signed byte in AL or a signed word from
some source with a signed word in AX.

Syntax: IMUL Source

Eg: IMUL BH

 AAM (BCD ADJUST AFTER MULTIPLY) - Used to adjust ASCII codes after multiplication.

Instructions to perform division

 DIV − Used to divide the unsigned word by byte or unsigned double word by word.

Syntax: DIV Source

Eg: DIV BL

15
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 IDIV − Used to divide the signed word by byte or signed double word by word.

Syntax: IDIV Source

Eg: IDIV BL

 AAD − Used to adjust ASCII codes after division.

 CBW (Convert Byte to Word) − Used to fill the upper byte of the word with the copies of sign bit of the
lower byte.

 CWD (Convert Word to Double Word) − Used to fill the upper word of the double word with the sign bit of
the lower word.

Bit Manipulation Instructions

These instructions are used to perform operations where data bits are involved, i.e. operations like
logical, shift, etc.

Instructions to perform logical operation

 NOT − Used to invert each bit of a byte or word.

Syntax: NOT Destination

Eg: NOT BX

 AND − Used for adding each bit in a byte/word with the corresponding bit in another byte/word.

Syntax: AND Destination, Source

Eg: AND BH, CL

 OR − Used to multiply each bit in a byte/word with the corresponding bit in another byte/word.

Syntax: OR Destination, Source

Eg: OR AH, CL

 XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with the corresponding bit in
another byte/word.

Syntax: XOR Destination, Source

Eg: XOR CL, BH

16
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 TEST − Used to add operands to update flags, without affecting operands.

Syntax: TEST Destination, Source


Eg: TEST AL, BH

Instructions to perform shift operations

 SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in LSBs.
Syntax: SAL Destination, Count
SHL Destination, Count

Eg: SAL CX, 1

 SHR − Used to shift bits of a byte/word towards the right and put zero(S) in MSBs.
Syntax: SHR Destination, Count

Eg: SHR BP, 1

 SAR − Used to shift bits of a byte/word towards the right and copy the old MSB into the new MSB.
Syntax: SAR Destination, Count

Eg: SAR DX, 1

Instructions to perform rotate operations

 ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to Carry Flag [CF].

Syntax: ROL Destination, Count

Eg: ROL AX, 1

17
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to Carry Flag [CF].

Syntax: ROR Destination, Count

Eg: ROR BL, 1

 RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to MSB.

Syntax: RCR Destination, Count

Eg: RCR BX, 1

 RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to LSB.

Syntax: RCL Destination, Count

Eg: RCL DX, 1

String Instructions

String is a group of bytes/words and their memory is always allocated in a sequential order.

 REP − Used to repeat the given instruction till CX ≠ 0.

 REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.

 REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.

 COMS/COMPSB/COMPSW (COMPARE STRING BYTES OR STRING WORDS) − Used to compare two string
bytes/words.

18
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another.

Syntax: MOVS Destination String Name, Source String Name

MOVSB Destination String Name, Source String Name

MOVSW Destination String Name, Source String Name

 INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided memory location.

 OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory location to the I/O
port.

 SCAS/SCASB/SCASW (SCAN A STRING BYTE OR A STRING WORD) − Used to scan a string and compare its
byte with a byte in AL or string word with a word in AX.

 STOS / STOSB / STOSW (STORE STRING BYTE OR STRING WORD)

 LODS/LODSB/LODSW (LOAD STRING BYTE INTO AL OR STRING WORD INTO AX) − Used to store the string
byte into AL or string word into AX.

Program Execution Transfer Instructions (Branch and Loop Instructions)

These instructions are used to transfer/branch the instructions during an execution. Instructions to transfer
the instruction during an execution without any condition

 CALL (CALL A PROCEDURE) − Used to call a procedure and save their return address to the stack.

 RET − Used to return from the procedure to the main program.

 JMP (UNCONDITIONAL JUMP TO SPECIFIED DESTINATION) − Used to jump to the provided address to
proceed to the next instruction.

Instructions to transfer the instruction during an execution with some conditions

 JA/JNBE (JUMP IF ABOVE / JUMP IF NOT BELOW OR EQUAL) − Used to jump if above/not below/equal
instruction satisfies.

 JAE/JNB (JUMP IF ABOVE OR EQUAL / JUMP IF NOT BELOW) − Used to jump if above/not below instruction
satisfies.

 JBE/JNA (JUMP IF BELOW OR EQUAL / JUMP IF NOT ABOVE) − Used to jump if below/equal/ not above
instruction satisfies.

19
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 JC (JUMP IF CARRY) − Used to jump if carry flag CF = 1

 JE/JZ (JUMP IF EQUAL / JUMP IF ZERO) − Used to jump if equal/zero flag ZF = 1

 JG/JNLE (JUMP IF GREATER / JUMP IF NOT LESS THAN OR EQUAL) − Used to jump if greater/not less
than/equal instruction satisfies.

 JGE/JNL (JUMP IF GREATER THAN OR EQUAL / JUMP IF NOT LESS THAN) − Used to jump if greater
than/equal/not less than instruction satisfies.

 JL/JNGE (JUMP IF LESS THAN / JUMP IF NOT GREATER THAN OR EQUAL) − Used to jump if less than/not
greater than/equal instruction satisfies.

 JLE/JNG (JUMP IF LESS THAN OR EQUAL / JUMP IF NOT GREATER) − Used to jump if less than/equal/if not
greater than instruction satisfies.

 JNC (JUMP IF NO CARRY) − Used to jump if no carry flag (CF = 0)

 JNE/JNZ (JUMP NOT EQUAL / JUMP IF NOT ZERO) − Used to jump if not equal/zero flag ZF = 0

 JNO − Used to jump if no overflow flag OF = 0

 JNP/JPO (JUMP IF NO PARITY / JUMP IF PARITY ODD) − Used to jump if not parity/parity odd PF = 0

 JNS (JUMP IF NO OVERFLOW) − Used to jump if not sign SF = 0

 JO (JUMP IF OVERFLOW) − Used to jump if overflow flag OF = 1

 JP/JPE (JUMP IF PARITY / JUMP IF PARITY EVEN) − Used to jump if parity/parity even PF = 1

 JS (JUMP IF SIGNED / JUMP IF NEGATIVE) − Used to jump if sign flag SF = 1

Processor Control Instructions

These instructions are used to control the processor action by setting/resetting the flag values.

 STC − Used to set carry flag CF to 1

 CLC − Used to clear/reset carry flag CF to 0

 CMC − Used to put complement at the state of carry flag CF.

 STD − Used to set the direction flag DF to 1

 CLD − Used to clear/reset the direction flag DF to 0

20
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
 STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.

 CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.

Iteration Control Instructions

These instructions are used to execute the given instructions for number of times.

 LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX = 0

 LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 & CX = 0

 LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0 & CX = 0

 JCXZ − Used to jump to the provided address if CX = 0

Machine control Instructions

The Machine control Instructions control the bus usage and execution.

 WAIT – Wait for TEST input pin to go low

 HLT – Halt the process

 NOP - No operation

 ESC – Escape to external device

 LOCK - Bus lock instruction prefix

ASSEMBLER DIRECTIVES

Assembler directives help the assembler to correctly understand the assembly language programs
to prepare the codes. Another type of hint which helps the assembler to assign a particular constant with a
label or initialize particular memory locations or labels with constants is called an operator. Rather, the
operators perform the arithmetic and logical tasks unlike directives that just direct the assembler to correctly
interpret the program to code it appropriately. The following directives are commonly used in the assembly
language programming practice using Microsoft Macro Assembler (MASM) or Turbo Assembler (TASM).

21
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
DB: Define Byte

The DB directive is used to reserve byte or bytes of memorylocations in the available memory.

LIST DB 0lH, 02H, 03H, 04H

This statement directs the assembler to reserve four memory locations for a list named LIST andinitialize
them with the above specified four values.

DW: Define Word

It makes the assembler reserve the number of memory words (16-bit) instead of bytes. Some
examples are given to explain this directive.

Examples WORDS DW 1234H, 4567H, 78ABH, 045CH

DQ: Define Quad word

This directive is used to direct the assembler to reset 4words (8 bytes) of memory for the
specified variable and may initialize it with the specified values.

DT: Define Ten Bytes

The DT directive directs the assembler to define the specified variable requiring l -bytes for its storage
and initialize the 10bytes with the specified values.

ASSUME: Assume Logical Segment Name

The ASSUME directive is used to inform the assembler, the names of the logical segments to be
assumed for different segments used in the program. In the assembly language program, each segment is
given a name.

For example, the code segment may be given the name CODE, data segment may be given the
name DATA etc.

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(segment) allotted by the operating system for the
label CODE, while loading.

22
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
ASSUME DS:

DATA indicates to the assembler that the data items related to the program, are available in a
logical segment named DATA, and the DS register is to be initialized by the segment Address value decided by
the operating system for the data segment, while loading.

END: END of Program


The END directive marks the end of an assembly language program. When the assembler comes
across this END directive, it ignores the source lines available later on. Hence, it should be ensured that the
END statement should be the last statement in the file and should not appear in between. ENDP: END of
Procedure. In assembly language programming, the subroutines are called procedures. Thus, procedures may
be independent program modules which return particular results or values to the calling programs. The ENDP
directive is used to indicate the end of a procedure.

PROCEDURE STAR
.
.
STAR ENDP

23
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
ENDS: END of Segment
This directive marks the end of a logical segment.
DATA SEGMENT
.
.
.
DATA ENDS
ASSUME CS: CODE, DS:DATA CODE SEGMENT.
.
.
.C
O
D
E
E
N
D
S
E
N
D

The above structure represents a simple program containing two segments named DATA and
CODE. The data related to the program must lie between the DATA SEGMENT and DATA ENDS statements.
Similarly, all the executable instructions must lie between CODE SEGMENT and CODE ENDS statements.

EVEN: Align on Even Memory Address

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.

24
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
EQU: Equate

The directive EQU is used to assign a label with a value or a symbol. Theuse of this directive is just to reduce
the recurrence of the numerical values or constants in a program code.

Example
LABEL
EQU
0500H
ADDITI
ON EQU
ADD
The first statement assigns the constant 500H with the label LABEL, while the second statement
assigns another label ADDITION with mnemonic ADD.

EXTRN: External and Public

The directive EXTRN informs the assembler that the names, procedures and labels declared after
this directive have already been defined in some other assembly language modules.

GROUP: Group the Related segment

The directive is used to form logical groups of segments with similar purpose or type. This
directive is used to inform the assembler to form a logical group of the following segment names.

PROGRAM GROUP CODE, DATA, STACK

The above statement directs the loader/linker to prepare an EXE file such that CODE, DATA and
STACK segment must lie within a 64kbyte memory segment that is named as PROGRAM. Now, for the
ASSUME statement, one can use the label PROGRAM rather than CODE, DATA and STACK as shown.

ASSUME CS: PROGRAM, DS: PROGRAM, SS: PROGRAM


LABEL: Label

The Label directive is used to assign a name to the current content of the location counter. At the
start of the assembly process, the assembler initializes a location counter to keep track of memory locations
assigned to the program.

25
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
LENGTH: Byte Length of a Label

This directive is not available in MASM. This is used to refer to the length of a data array or a string.

MOV CX, LENGTH ARRAY

LOCAL:

The labels, variables, constants or procedures declared LOCAL in a module are to be used only by that
module.

NAME: Logical Name of a Module

The NAME directive is used to assign a name to an assembly language program module. The
module may now be referred to by its declared name.

OFFSET: Offset of a Label

When the assembler comes across the OFFSET operator along with a label, it first computes the
16-bit displacement (also called as offset interchangeably) of the particular label, and replaces the string
'OFFSET LABEL' by the computed displacement.

ORG: Origin

The ORG directive directs the assembler to start the memory allotment for the particular segment,
block or code from the declared Addressing. The ORG statement while starting the assembly process for a
module, the assembler initializes a location counter to keep track of the allotted addresses for the module. If
the ORG statement is not written in the program, the location counter is initialized to 0000. If an ORG 200H
statement is present at the starting of the code segment of that module, then the code will start from 200H
Addressing code segment.

PROC: Procedure

The PROC directive marks the start of a named procedure in the statement

26
UNIT-1 THE 8086 MICROPROCESSOR ECE DEPARTMENT
PTR: Pointer

The pointer operator is used to declare the type of a label, variable or memory operand. The operator
PTR is prefixed by either BYTE or WORD. If the prefix is BYTE, then the particular label, variable or memory
operand is treated as an 8-bit quantity while if WORD is the prefix, then it is treated as a 16- bit quantity.

Example:

MOV AL, BYTE PTR [SI];

Moves content of memory location addressed by SI (8-bit) to AL

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 place of ‘SEG label’. The example given below explains the use
of SEG operator.

Example

MOV AX, SEG ARRAY; This statement moves the segment address

SEGMENT: Logical Segment

The SEGMENT directive marks the starting of a logical segment. The started segment is also
assigned a name, i.e. label, by this statement. The SEGMENT and ENDS directive must bracket each logical
segment of a program.

TYPE:

The TYPE operator directs the assembler to decide the data type of the specified label and replaces
the 'TYPE label' by the decided data type. For the word type variable, the data type is 2, for double word
type, it is 4, and for byte type, it is 1.

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. The following
statement declares the procedure ROUTINE as a global label.

27

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy