DOC-20231206-WA0017.
DOC-20231206-WA0017.
8085 8086
8-bit microprocessor 16-bit microprocessor
216 memory locations 220 memory locations
Sequential facility Pipelined architecture available
Low speed High speed
It does not have much operational It allows to have much large set of operation
instructions when compared to 8086 and instruction.
The internal functions of the 8086 processor are portioned logically into two
processing units.
1. Bus Interface Unit (BIU)
2. Execution unit (EU)
➢ BIU & EU function independently.
The BIU contains The EU contains
1.Segment registers 1.ALU
2.Instruction pointer 2.General purpose registers
3. Instruction queue. 3. Index registers
4. Pointers
5.Flag register
9. Give examples for some assembler directives that are specific to 8086
assembly language.***
The general assembler directives are: ASSUME , EXTRN, GROUP, INCLUDE,
LABEL, MACRO, ORG, PTR, PROC, PUBLIC, RECORD, SEGMENT, STRUC,
EVEN, EQU, END, ENDM, ENDS, ENDP, DT, DQ , DD,DW, DB.
After an ASSUME is put into effect, the assembler watches for changes to the values of
the given registers. ERROR generates an error if the register is used. NOTHING removes
register error-checking.
MICROPROCESSOR AND
MICROCONTROLLER 2 MARKS Q&A
Examples:
ASSUME CS : CODE
ASSUME DS : DATA
AAA:
ASCII Adjust for Addition instruction adjusts the binary result of ADD or ADC
instruction.If bits 0-3 of AL contain a value greater than 9, or if the Auxiliary carry
flag is set, the CPU adds 06 to AL and adds 1 to AH. The bits 4-7 are set to zero.
(AL) ← (AL) + 6
(AH) ← (AH) + 1
MICROPROCESSOR AND
MICROCONTROLLER 2 MARKS Q&A
(AF) ← 1
Example:
AAA
Before execution After execution
00 0B 01 01
AH AL AH AL
AAS:
ASCII Adjust for Subtraction instruction adjusts the binary result of a SUB or SBB
instruction.
If D3-D0 OF AL > 9
(AL) ← (AL) - 6
(AH) ← (AH) - 1
(AF) ← 1
AAM:
ASCII Adjust for Multiplication instruction adjusts the binary results of a MUI
instruction. AL is divided by 10(0AH) and the quotient is stored in AH. The
remainder is stored in AL.
(AH) ← (AL/0AH)
(AL) ← Remainder
AAD:
ASCII Adjust for Division instruction adjusts unpacked BCD dividend in AX before
a division operation. AH is multiplied 10(0AH) and added to AL. AH is set to zero.
(AL) ← (AH X 0AH) + (AL)
(AH) ← 0
BHE A0 Characteristics
0 0 Whole word
0 1 Upper byte from/to ODD address
1 0 Lower byte from/to EVEN address
1 1 None
Program, data and stack memories occupy the same space. The total addressable
memory size is 1 MB. As the most of the processor instructions use 16-bit pointers,
the processor can effectively address only 64KB of memory. To access memory
outside of 64 KB the CPU uses special segment registers to specify where the code,
stack and data 64 KB segments are positioned within 1 MB of memory.
Interrupt Priority
INT n, INTO, Divide Error Highest
NMI ↓
INTR ↓
Single step lowest
Table: the priority of interrupts of 8086.
The software interrupts except Single Step interrupt have the highest priority;
followed by NMI, followed by INTR. Single step interrupt has the least priority. The
8086 checks for internal interrupts before for any hardware interrupt. Therefore
software interrupts have higher priority than hardware interrupt.
MICROPROCESSOR AND
MICROCONTROLLER 2 MARKS Q&A
22. What are the interrupts in 8086***
Programmable
Interrupt controller
NMI Requesting device
NMI
8086 CPU Intel
8259A
Interrupt Logic INTR
PIC
23. How the physical address for fetching the next instruction to be
executed is obtained in 8086?
The physical address is obtained by appending four zeros to the content present in
CS register and then adding the content of IP register with the above value.
1. ARCHITECTURE OF 8086:
The internal architecture of 8086 is divided into two separate units. They are
The BIU is needed to fetch instruction, read operands, and write results. The
execution unit is used to execute instructions that have already been fetched by the BIU.
• The BIU is used to handle all transfers of data and addresses on the buses for the
Execution unit.
• The BIU is used to send addresses, fetch instructions from the memory, read data
from ports and memory and write data to ports and memory.
• The BIU contains segment registers, instruction pointer and the instruction queue.
QUEUE
• These registers are used to hold the upper 16-bits of the starting address of the logical
group of memory, called the segment.
• The address of the memory bytes that need to be accessed is generated with the help
of address contained in the segment registers and other registers.
CS REGISTER:
• This register contains the initial address of the code segment (CS).
• This address plus the offset value contained in the instruction pointer (IP) indicates
the address of an instruction to be fetched for execution.
SS REGISTER:
• The stack segment (SS) register contains the initial address of the stack segment. This
address plus the value contained in the stack pointer (SP) is used for stack operations.
DS REGISTER:
• The data segment (DS) register contains the initial address of the current data
segment.
• This address plus the offset value in instruction causes a reference to a specific
location in the data segment.
ES REGISTER:
1. The segment registers permit a program and its data to be placed in different areas of
memory each time the program is executed.
2. The segment registers facilitate the use of separate memory areas for instructions, its data,
and the stack.
3. The segment registers are used to allow the instruction, data, or stack portion of a program
to be more than 64 K bytes long. The above can be achieved by using more than one code,
data, or stack segment.
4. The segment registers are used to allow the memory capacity to be 1MB even though the
address associated with the individual instructions are only 16-bits.
• The instruction pointer register contains a 16-bit offset address of the instruction that
is to be executed next.
• The value contained in the instruction pointer is called as an offset because this value
must be added to the base address of the code segment, which is available in the CS
register to find the 20-bit physical address.
• The value of the instruction pointer is incremented after executing every instruction.
The 8086 has four 16-bit general purpose registers: AX, BX, CX and DX. The above 16-bit
registers can also be used as 8-bit registers. This BH, BL, CH, CL, DH, DL.
AX REGISTER:
BX REGISTER:
CX REGISTER:
DX REGISTER:
• Base pointer register is also used to access the data from the stack.
• The value in Sp always represents the offset of the top of the stack.
• BP register also contains an offset relative to SS register.
• With the help of BP register, it is possible to access any location within the stack
segment of the memory.
INDEX REGISTER:
• The 8086 contain two index registers Source Index (SI) register and Destination Index
(DI) register.
• The main use of three register is to hold the offset of a data in one segments.
A flag register is a 16-bit register. A flag is a flip-flop. The flag register contains nine active
flags. Out of the above nine flags, six flags are called status flags or conditional flags and the
remaining three flags are called control flags.
The status Flags are used to indicate some condition produced by an instruction. The Execution
Unit sets or resets these flags at the completion of execution of the arithmetic or logical
instruction.
The three control flags are:
The control flags are set or reset by the specific instruction. The following figure shows
the format of the 8086 flag register. The first row indicates the bit positions and the second
row indicates the corresponding flags.
CF is set if there is a carry or borrow for the most significant bit from addition or subtraction
operation respectively.
PF is set, if the result contains an even number of 1’s. PF is reset, if the result conatins an odd
number of 1’s.
AF is set if there is a carry from the low nibble into the high nibble during addition or a borrow
from the high nibble into the low nibble during subtraction of the low order 8 -bit of a 16-bit
number. Otherwise, Af is reset.
SF is set if the most significant bit of the result is one; otherwise, it is zero. The value of SF
=0 indicates that the sign of the result is positive. If SF =1, the result is negative number.
CONTROL FLAGS
If TF is set, the 8086 works in the single step mode. In the single step mode, one instruction is
executed at a time. This type of operation is very useful for debugging programs.
If IF is set to 1, the processor recognizes all the interrupts; if IF is cleared to zero, the processor
ignores interrupts that come from the external devices.
OF is set if there is an arithmetic overflow, i.e., if the size of the result exceeds the capacity of
the destination location.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
• The Microprocessor 8086 is a 16-bit CPU available in different clock rates and
packaged in a 40 pin CERDIP or plastic package.
• The 8086 operates in single processor or multiprocessor configuration to achieve high
performance. The pins serve a particular function in minimum mode (single processor
mode) and other function in maximum mode configuration (multiprocessor mode).
• The Microprocessor 8086 is a 16-bit CPU available in different clock rates and
packaged in a 40 pin CERDIP or plastic package.
• The 8086 operates in single processor or multiprocessor configuration to achieve high
performance. The pins serve a particular function in minimum mode (single processor
mode) and other function in maximum mode configuration (multiprocessor mode ).
• The 8086 signals can be categorized in three groups.
o The first are the signal having common functions in minimum as well as
maximum mode.
o The second are the signals which have special functions for minimum mode
o The third are the signals having special functions for maximum mode.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
• BHE/S7: The bus high enable is used to indicate the transfer of data over the higher
order (D15-D8) data bus as shown in table. It goes low for the data transfer over D15 -
D8 and is used to derive chip selects of odd address memory bank or peripherals. BHE
is low during T1 for read, write and interrupt acknowledge cycles, whenever a byte is
to be transferred on higher byte of data bus. The status information is available during
T2, T3 and T4. The signal is active low and tristated during hold. It is low during T1
for the first pulses of the interrupt acknowledge cycle.
• RD – Read: This signal on low indicates the peripheral that the processor is
performing memory or I/O read operation. RD is active low and shows the state for
T2, T3, Tw of any read cycle. The signal remains tristated during the hold
acknowledge.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
• READY: This is the acknowledgement from the slow device or memory that they have
completed the data transfer. The signal made available by the devices is synchronized
by the 8284A clock generator to provide ready input to the 8086. the signal is active
high.
• INTR-Interrupt Request: This is a triggered input. This is sampled during the last
clock cycles of each instruction to determine the availability of the request. If any
interrupt request is pending, the processor enters the interrupt acknowledge cycle. This
can be internally masked by resulting the interrupt enable flag. This signal is active
high and internally synchronized.
• TEST: This input is examined by a ‘WAIT’ instruction. If the TEST pin goes low,
execution will continue, else the processor remains in an idle state. The input is
synchronized internally during each clock cycle on leading edge of clock.
• CLK- Clock Input: The clock input provides the basic timing for processor operation
and bus control activity. It’s an asymmetric square wave with 33% duty cycle.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
The following pin functions are for the minimum mode operation of 8086,
• INTA – Interrupt Acknowledge: This signal is used as a read strobe for interrupt
acknowledge cycles. i.e. when it goes low, the processor has accepted the interrupt.
• ALE – Address Latch Enable: This output signal indicates the availability of the
valid address on the address/data lines, and is connected to latch enable input of latches.
This signal is active high and is never tristated.
• DT/R – Data Transmit/Receive: This output is used to decide the direction of data
flow through the transceivers (bidirectional buffers). When the processor sends out
data, this signal is high and when the processor is receiving data, this signal is low.
• DEN – Data Enable: This signal indicates the availability of valid data over the
address/data lines. It is used to enable the transceivers (bidirectional buffers) to
separate the data from the multiplexed address/data signal. It is active from the middle
of T2 until the middle of T4. This is tristated during ‘hold acknowledge’ cycle.
• HOLD, HLDA- Acknowledge: When the HOLD line goes high, it indicates to the
processor that another master is requesting the bus access. The processor, after
receiving the HOLD request, issues the hold acknowledge signal on HLDA pin, in the
middle of the next clock cycle after completing the current bus cycle.
• At the same time, the processor floats the local bus and control lines. When the
processor detects the HOLD line low, it lowers the HLDA signal. HOLD is an
asynchronous input, and is should be externally synchronized. If the DMA request is
made while the CPU is performing a memory or I/O cycle, it will release the local bus
during T4 provided:
2. The current cycle is not operating over the lower byte of a word.
The following pin functions are applicable for maximum mode operation of 8086,
• S2, S1, S0 – Status Lines: These are the status lines which reflect the type of operation,
being carried out by the processor. These become activity during T4 of the previous
cycle and active during T1 and T2 of the current bus cycles.
• LOCK: This output pin indicates that other system bus master will be prevented from
gaining the system bus, while the LOCK signal is low. The LOCK signal is activated
by the ‘LOCK’ prefix instruction and remains active until the completion of the next
instruction. When the CPU is executing a critical instruction which requires the system
bus, the LOCK prefix instruction ensures that other processors connected in the system
will not gain the control of the bus.
The 8086, while executing the prefixed instruction, asserts the bus lock signal output,
which may be connected to an external bus controller. By prefetching the instruction, there is
a considerable speeding up in instruction execution in 8086. This is known as instruction
pipelining.
S2 S1 S1 INDICATION
0 0 0 Interrupt Acknowledgement
0 0 1 Read I/O port
0 1 0 Write I/O port
0 1 1 Halt
1 0 0 Code Access
1 0 1 Read Memory
1 1 0 Write Memory
1 1 1 Passive
• At the starting the CS:IP is loaded with the required address from which the execution
is to be started. Initially, the queue will be empty an the microprocessor starts a fetch
operation to bring one byte (the first byte) of instruction code, if the CS:IP address is
odd or two bytes at a time, if the CS:IP address is even.
• The first byte is a complete opcode in case of some instruction (one byte opcode
instruction) and is a part of opcode, in case of some instructions ( two byte opcode
instructions), the remaining part of code lie in second byte.
• The second byte is then decoded in continuation with the first byte to decide the
instruction length and the number of subsequent bytes to be treated as instruction data.
The queue is updated after every byte is read from the queue but the fetch cycle is
initiated by BIU only if at least two bytes of the queue are empty and the EU may be
concurrently executing the fetched instructions.
• The next byte after the instruction is completed is again the first opcode byte of the
next instruction. A similar procedure is repeated till the complete execution of the
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
program. The fetch operation of the next instruction is overlapped with the execution
of the current instruction. As in the architecture, there are two separate units, namely
Execution unit and Bus interface unit.
• RQ/GT0, RQ/GT1 – Request/Grant : These pins are used by the other local bus master
in maximum mode, to force the processor to release the local bus at the end of the
processor current bus cycle.
• Each of the pin is bidirectional with RQ/GT0 having higher priority than RQ/GT1.
RQ/GT pins have internal pull-up resistors and may be left unconnected.
Request/Grant sequence is as follows:
1. A pulse of one clock wide from another bus master requests the bus access to
8086.
2. During T4(current) or T1(next) clock cycle, a pulse one clock wide from 8086 to
the requesting master, indicates that the 8086 has allowed the local bus to float and
that it will enter the ‘hold acknowledge’ state at next cycle. The CPU bus interface
unit is likely to be disconnected from the local bus of the system.
3. A one clock wide pulse from another master indicates to the 8086 that the hold
request is about to end and the 8086 may regain control of the local bus at the next
clock cycle. Thus each master to master exchange of the local bus is a sequence of
3 pulses. There must be at least one dead clock cycle after each bus exchange. The
request and grant pulses are active low. For the bus request those are received while
8086 is performing memory or I/O cycle, the granting of the bus is governed by the
rules as in case of HOLD and HLDA in minimum mode.
One bank is connected to the lower half of the 16-bit data bus (D0 – D7) and contains even
address bytes. i.e., when A0 bit is low, the bank is selected. The other bank is connected to the
upper half of the data bus (D8 - D15) and contains odd address bytes. i.e., when A0 is high
and BHE (Bus High Enable) is low, the odd bank is selected. A specific byte within each bank
is selected by address lines A1-A19.
Data can be accessed from the memory in four different ways. They are:
1. By external signal
• When the quotient from either a DIV or IDIV instruction is too large to fit in the
result register; 8086 will automatically execute type 0 interrupt.
• As the name suggests, this interrupt cannot be disabled by any software instruction
• This interrupt is activated by low to high transition on 8086 NMI input pin
• In response 8086 will do a type 2 interrupt
• It is used to check overflow condition after any signed arithmetic operation in the
system.
• For example, if you add the 8-bit signed number 0111 1000(+120 decimal) and the 8
bit signed number 0110 0010 (-98 decimal).
• In signed number, MSB is reserved for sign and other bit represent magnitude of the
number.
• In the previous example, after addition of two 8-bit signed numbers result is negative,
since it is too large to fit in 7bits.
• To delete this condition in the program you can put interrupt on overflow instruction,
INTO, immediately after the arithmetic instruction in the program.
• If the overflow flag is not set when the 8086 executes the INTO instructions, the
instruction will simply function as a NOP (no operation).
• However, if the overflow flag is set, indicating an overflow error, the 8086 will
executes type4 interrupt after executing the INTO instruction.
• Another way to detect and respond to the overflow error in a program is to put the
jump if overflow (JO) instruction immediately after the arithmetic instruction.
• If the overflow flag is set as a result of arithmetic operation, execution will jump to
the address specified in the JO instruction.
• At this address you can put an error routine which response in the way you want to
overflow.
Software interrupts
Type 0-255:
• The 8025 INT instruction can be used to cause the 8086 to do one of the 256 possible
interrupt types.
• The interrupt type is specified by the number as a part of the instructions.
• We can use an INT2 instruction to send execution to an NMI interrupt service routine.
• With the s/w interrupts u can call the desired routines from many different programs in a
system.
• The BIOS (Basic Input Output System) routines are called INT instructions. we will
summarize interrupt response and how it is serviced by going through following steps.
2. It disables the single step & the INTR input by clearing the trap flag & interrupt flag in
the flag register.
3. It saves the current CS &IP register contents by pushing them on the stack.
4. Once these values are loaded in CS & IP, 8086 will fetch the instruction from the new
address which is the starting address of ISR
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
5. An IRET instruction at the end of ISR gets the previous values of CS &IP by popping
the CS and IP from the stack.
6. At the end of flag register contents are copied back into flag register by popping the flag
register from stack.
1. The 8086 has 2 interrupt i) interrupt acknowledge machine cycle the 8086 floats the
data bus line AD0-AD15.
2. Once the 8086 receives the interrupt type, it pushes the flag register on the stack, Clears
TF &IF, pushes the CS & IP values of the next instruction on the stack.
3. The 8086 then gets the new value of IP from the memory address = 4 times the interrupt
type & CS value from memory address = 4 times the interrupt number plus2.
• Implicit
• Explicit
• Both Implicit and Explicit.
Implicit operands mean that the instruction by definition has some specific operands. The
programmers do NOT select these operands.
Explicit operands mean the instruction operates on the operands specified by the
programmer.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
The location of an operand value in memory space is called the Effective Address (EA)
• Immediate addressing
• Register addressing
• Memory addressing
• I/O port addressing
In this addressing mode, the operand is stored as part of the instruction. The immediate
operand, which is stored along with the instruction, resides in the code segment -- not in the
data segment. This addressing mode is also faster to execute an instruction because the operand
is read with the instruction from memory. Here are some examples:
• reg16: 16-bit general registers: AX, BX, CX, DX, SI, DI, SP or BP.
• reg8: 8-bit general registers: AH, BH, CH, DH, AL, BL, CL, or DL.
• Sreg: segment registers: CS, DS, ES, or SS. There is an exception: CS cannot be a
destination.
For register addressing modes, there is no need to compute the effective address. The operand
is in a register and to get the operand there is no memory access involved.
2. Only one of the operands can be a segment register. You cannot move data from one
segment register to another with a single mov instruction. To copy the value of cs to ds, you
would have to use some sequence like:
You should never use the segment registers as data registers to hold arbitrary values. They
should only contain segment addresses.
Memory (RAM) is the main component of a computer to store temporary data and machine
instructions. In a program, programmers many times need to read from and write into memory
locations.
1. Direct Addressing
2. Register indirect addressing
3. Based addressing
4. Indexed addressing
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
The instruction mov al, ds:[8088h] loads the AL register with a copy of the byte at memory
location 8088h. Likewise, the instruction mov ds: [1234h],dl stores the value in the dl register
to memory location 1234h. By default, all displacement-only values provide offsets into the
data segment. If you want to provide an offset into a different segment, you must use a segment
override prefix before your address. For example, to access location 1234h in the extra
segment (es) you would use an instruction of the form mov ax, es:[1234h]. Likewise, to access
this location in the code segment you would use the instruction mov ax, cs: [1234h]. The ds:
prefix in the previous examples is not a segment override.
The instruction mov al, ds:[8088h] is same as mov al, [8088h]. If not mentioned DS register
is taken by default.
The 80x86 CPUs let you access memory indirectly through a register using the register indirect
addressing modes. There are four forms of this addressing mode on the 8086, best
demonstrated by the following instructions:
Code Example
The [bx], [si], and [di] modes use the ds segment by default. The [bp] addressing mode uses
the stack segment (ss) by default. You can use the segment override prefix symbols if you wish
to access data in different segments. The following instructions demonstrate the use of these
overrides:
Intel refers to [bx] and [bp] as base addressing modes and bx and bp as base registers (in fact,
bp stands for base pointer). Intel refers to the [si] and [di] addressing modes as indexed
addressing modes (si stands for source index, di stands for destination index). However, these
addressing modes are functionally equivalent. This text will call these forms register indirect
modes to be consistent.
8-bit or 16-bit instruction operand is added to the contents of a base register (BX or BP), the
resulting value is a pointer to location where data resides.
Code Example
If bx=1000h
si=0880h
Mov AL, [1000+880]
Mov AL,[1880]
If bx contains 1000h, then the instruction mov cl, [bx+20h] will load cl from memory location
ds:1020h. Likewise, if bp contains 2020h, mov dh, [bp+1000h] will load dh from location
ss:3020. The offsets generated by these addressing modes are the sum of the constant and the
specified register. The addressing modes involving bx, si, and di all use the data segment, the
[bp+disp] addressing mode uses the stack segment by default. As with the register indirect
addressing modes, you can use the segment override prefixes to specify a different segment:
Based Indexed Addressing Modes & Based Indexed Plus Displacement Addressing Mode
The based indexed addressing modes are simply combinations of the register indirect
addressing modes. These addressing modes form the offset by adding together a base register
(bx or bp) and an index register (si or di). The allowable forms for these addressing modes are:
Code Example
These addressing modes are a slight modification of the base/indexed addressing modes with
the addition of an eight bit or sixteen bit constant. The following are some examples of these
addressing modes
Code Example
The data transfer instructions transfers’ data from one register/memory locations to other
register/memory locations. All the store, move, load, exchange, input and output instructions
belong to this category. These instructions move single byte or word between a register and
I/O ports. Some of the data transfer instructions are listed below.
• MOV d,s
• PUSH d
• POP d
• LEA reg,mem
• LDS reg,mem
2. Arithmetic instructions
This type of instructions usually perform the arithmetic operations, like Addition, Subtraction,
Multiplications, Division, Increment and Decrement operation along with respective ASCII
and decimal adjust instructions. The operands are either the registers or memory locations or
immediate data depending upon the addressing mode. Some of the arithmetic instructions are
given below.
• ADD a,b
• ADC a,b
• AAA
• INC reg/mem
• SUB a,b
• SBB a,b
• CMP a,b
• MUL reg,mem
• DIV reg,mem
The following are the examples for some of the above mentioned instructions.
These types of instructions are used for carrying out the bit by bit shift, rotate in basic logical
operations. All the condition code flags are affected depending upon the result. The 8086
provides three groups of bit manipulation instructions. Some of the instructions are listed
below.
• AND a, b
• OR a, b
• XOR a, b
• SHL/SAL mem / reg, CNT
• SHR/SAR mem /reg, CNT
• RCL mem/reg, CNT
• RCR mem/reg, CNT
The following are the example for the above mentioned instructions.
1. AND, Logical AND, Logical OR, Logical Inverter and Logical XOR
The source operand that may be available immediately, register or a memory location ANDed
bit by bit to the destination operand that may be a register or a memory location.
The instructions shift the operand word or byte bit by bit to the left and insert zeros in the
newly introduced least significant bits.
The instructions are same as SHL/SAL; the only difference is shift the operand word or byte
bit by bit to the right. The result is stored in the destination operand.
These instructions rotate the contents (bit-wise) of the destination operand right or left
respectively by the specified count through Carry flag (CF). In RCR, the Carry flag is pushed
in to the MSB of the operand, and the LSB is pushed into carry flag for each operation. In
RCL the carry flag for each operation.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
String instructions are available to MOVE, COMPARE or SCAS for a value as well as to
move string elements to and from the accumulator. A series of the data bytes or words
available is memory at consecutive locations, to be referred to collectively or word strings. For
referring to a string two parameters are required (a) string or end address of the sting (b) length
of the string. Some of the string manipulations are given below.
These instruction moves 8 or 16 bit data from the memory l0cation addressed by
SI to another set of destination location which is addressed by SI.
When two strings of bytes or words are to be compared the CMPs can be used. The length of
the strings must be stored in the CX register. If both strings are equal Z=1, other flags are
affected in the same way as CMP instruction.
In these instructions, the control is transferred to the specified location provided the result of
previous operation satisfies a particular condition, otherwise, the execution continuous in
normal flow sequence. All the conditional branch instructions use 8-bit signed displacement
these type of instructions do not affect any flag. The typical structure of the conditional branch
is follows.
If condition is true,
• JZ
• JNZ
• JS
• JNS
These instructions, transfers the execution control to the specified location independent of any
status or condition. The CS and IP are unconditionary, modified to the new CS and IP. The
8086 unconditional transfers are
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
• CALL[Unconditional call]
This instruction is used to call a subroutine form amain program. While executing this
instruction IP is incremented (i.e. address of the next instruction to be executed ) and CS on to
the stack with the flags and loads the CS and IP register respectively.
At the end of the subroutine, the RET must e executed, upon executing the previously stored
contents of IP and CS along with flags are retrieved into CS, IP and flag registers from the
stack and the main program will be executed the types of procedure and the SP contents.
They are
c) Return intersegment
• JMP[Unconditional JumP]
This instruction transfers the control of execution to the specified address using an 8 -bit or
16-bit displacement or CS unconditionally. No flags are affected by this instruction.
These instructions execute the part of the program from the label or address specified in the
instruction up to the loop instruction, CX number of times. These instructions are given below
8. Interrupt instructions
In the 8086, there are 256 interrupts are defined corresponding to the types from 00Hto FFH.
Where an Interrupt instruction executed, the TYPE byte N Is multiplied and the contents of IP
and CS of the interrupt service routine will be taken from the hexadecimal multiplication
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
(N*4) as offset address and 0000 as segment address. The interrupt instruction in8086 is
listed below.
First one directly modifies some of the flags of 8086, later control the bus usage and
execution.
7. ASSEMBLER DIRECTIVES
Assembly languages are low-level languages for programming computers, microprocessors,
microcontrollers, and other IC. They implement a symbolic representation of the numeric
machine Codes and other constants needed to program a particular CPU architecture. This
representation is usually defined by the hardware manufacturer, and is based on abbreviations
that help the programmer to remember individual instructions, registers. An assembler
directive is a statement to give direction to the assembler to perform task of the assembly
process.
It control the organization if the program and provide necessary information to the assembler
to understand the assembly language programs to generate necessary machine codes. They
indicate how an operand or a section of the program is to be processed by the assembler.
(d) The STRUCT (or STRUC) and ENDS directives (counted as one)
(g)ASSUME
(h) EXTERN
(i) GLOBAL
(j) SEGMENT
(k)OFFSET
(l) PROC
(m)GROUP
(n) INCLUDE
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
Declaration examples:
Byte1 DB 10h
Declaration examples:
Word DW 1234h
Declaration examples:
Dword1 DW 12345678h
4. STRUCT and ENDS directives to define a structure template for grouping data items.
(1) The STRUCT directive tells the assembler that a user defined uninitialized data structure
follows. The uninitialized data structure consists of a combination of the three supported data
types. DB, DW, and DD. The labels serve as zero-based offsets into the structure. The first
element's offset for any structure is 0. A structure element is referenced with the base "+"
operator before the element's name.
Syntax:
STRUCT
Structure_element_name element_data_type?
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
...
...
...
ENDS
(OR)
STRUC
Structure_element_name element_data_type?
...
...
...
ENDS
DECLARATION:
STRUCT
Byte1 DB?
Byte2 DB?
Word1 DW?
Word2 DW?
Dword1DW?
Dword2 DW?
ENDS
Use OF STRUCT:
The STRUCT directive enables us to change the order of items in the structure when, we
reform a file header and shuffle the data. Shuffle the data items in the file header and reformat
the sequence of data declaration in the STRUCT and off you go. No change in the code we
write that processes the file header is necessary unless you inserted an extra data element.
The EQU directive is used to give name to some value or symbol. Each time the assembler
finds the given names in the program, it will replace the name with the value or a symbol. The
value can be in the range 0 through 65535 and it can be another Equate declared anywhere
above or below.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
THIS BYTE
THIS WORD
THIS DWORD
A variable - declared with a DB, DW, or DD directive - has an address and has space reserved
at that address for it in the .COM file. But an Equate does not have an address or space reserved
for it in the .COM file.
Example:
DB 10
DW 1000
DD 4294967295
Buffed_ ptr EQU $ ; actually points to the next byte after the; 1024th byte in buffer.
(6) Extern:
It is used to tell the assembler that the name or label following the directive are I some other
assembly module. For example: if you call a procedure which is in program module assembled
at a different time from that which contains the CALL instructions ,you must tell the assembler
that the procedure is external the assembler will put information in the object code file so that
the linker can connect the two module together.
Example:
PROCEDURES-HERE ENDS
(7) GLOBAL: The GLOBAL directive can be used in place of PUBLIC directive .for a name
defined in the current assembly module; the GLOBAL directive is used to make the symbol
available to the other modules.
IT-T44 MICROPROCESSORS AND MICROCONTROLLERS
WORD tells the assembler that DIVISOR is a variable of type of word which is in another
assembly module or EXTERN.
(8) SEGMENT:
It is used to indicate the start of a logical segment. It is the name given to the the segment.
Example: the code segment is used to indicate to the assembler the start of logical segment.
It is used to identify the start of a procedure. It follows a name we give the procedure.
After the procedure the term NEAR and FAR is used to specify the procedure Example:
SMART-DIVIDE PROC FAR identifies the start of procedure named SMART-DIVIDE and
tells the assembler that the procedure is far.
(10) NAME:
It is used to give a specific name to each assembly module when program consists of several
modules.
Example: PC-BOARD used to name an assembly module which contains the instructions for
controlling a printed circuit board.
(11) INCLUDE:
It is used to tell the assembler to insert a block of source code from the named file into the
current source module. This shortens the source module. An alternative is use of editor block
command to cop the file into the current source module.
(12) OFFSET:
It is an operator which tells the assembler to determine the offset or displacement of a named
data item from the start of the segment which contains it. It is used to load the offset of a
variable into a register so that variable can be accessed with one of the addressed modes.
Example: when the assembler read MOV BX.OFFSET PRICES, it will determine the offset
of the prices.
(13) GROUP:
It can be used to tell the assembler to group the logical segments named after the directive into
one logical group. This allows the contents of all he segments to be accessed from the same
group. Example: SMALL-SYSTEM GROUP CODE, DATA, STACK-SEG.