CH 3
CH 3
CHAPTER THREE
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 1 of 38
8086 Assembly Language Programming and Instruction Sets
MOV [DI], BX ; the instruction copies the 16-bit content of BX into a memory
location ; offset by the value of EA specified in DI from the current
contents in DS. ; Now, if [DS] =7205H, [DI] =0030H, and [BX] =8765H,
then after MOV ; [DI], BX content of BX (8765H) is copied to memory
locations 72080H ; and 72081H.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 3 of 38
8086 Assembly Language Programming and Instruction Sets
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 4 of 38
8086 Assembly Language Programming and Instruction Sets
Example: MOV AL, LAST [SI+2]; This instruction copies the content of the 20-bit
address computed from the displacement LAST, SI+2 and DS into AL.
The following example shows how to address data element within the array with register
relative addressing.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 5 of 38
8086 Assembly Language Programming and Instruction Sets
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 6 of 38
8086 Assembly Language Programming and Instruction Sets
Figure 8 Two dimensional array accessing using base relative plus index addressing
In direct port addressing mode, the port number is an 8-bit immediate number operand.
This allows fixed access to ports numbered from 0-255.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 7 of 38
8086 Assembly Language Programming and Instruction Sets
Example:
OUT 05H, AL ; sends the contents of AL to 8-bit port 05
In indirect port addressing mode, the port number is taken from DX allowing 64K 8-bit
ports or 32K 16-bit ports.
Example:
IN AL, DX ; if [DX] =7890H, then this command copies 8-bit content of
; port 7890H into AL.
Note that the 16 and 8-bit I/O transfer must take place through AX and AL respectively.
In our previous discussion of the data addressing modes, we always used the DS register
to hold the 16-bit current memory location. Similarly, here in program memory
addressing, we use the CS register to hold this same value of the next instruction to be
executed. However, in case of direct intersegment jump the address could be any memory
segment. What this instruction does is it loads the CS with the immediate 16-bit address.
For that matter, this type of jump is also called far jump.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 8 of 38
8086 Assembly Language Programming and Instruction Sets
Like JMP instruction, CALL instruction also uses direct program addressing with
intersegment or far CALL instruction. Usually in both instructions, (JMP and CALL) the
name of the memory address, called a label is specified in the instruction instead of
address.
In JMP instruction, opcode takes one byte and displacement may take one or two bytes.
When displacement is one byte (8-bit), it is called short jump. When displacement is two
bytes (16-bit), it is called near jump. In both (short and near) cases only contents of IP
register are modified; contents of CS register are not modified. Such jumps are called
intrasegment jumps because jumps are within the current code segment.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 9 of 38
8086 Assembly Language Programming and Instruction Sets
Opcod
e
20000H EB
JMP [03]
20001H 05
20002H --
20003H -- Offset
20004H --
20005H
20006H
The relative JMP and CALL instructions can have either an 8-bit or 16-bit signed
displacement that allows a forward memory reference or a reverse memory reference.
PUSH Operations
This instruction decrements stack pointer by two and copies a word from the source to
the location where the stack points. The source must be a 16-bit (a word). The source
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 10 of 38
8086 Assembly Language Programming and Instruction Sets
can be a general purpose register, a segment register or memory. The way PUSH behaves
has been demonstrated in the following figure (PUSH AX, PUSH CX).
POP Operation
The POP instruction copies a word from the stack location pointed by the stack pointer to
the destination. The destination can be a general purpose register, a segment register, or
a memory location. After the word is copied to the specified location, the stack pointer is
automatically incremented by 2. The next figure shows the map of the stack after and
before the execution of POP DX and POP BX.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 11 of 38
8086 Assembly Language Programming and Instruction Sets
CALL Operation
The call instruction is used to transfer execution to a subprogram or procedure. There
are two basic types of CALL instructions, the near and far CALL. In the near CALL, the
next procedure resides in the same memory segment as the CALL instruction. When the
8086 executes a near call, the stack pointer is decremented by two and then copies the
offset the next instruction after the CALL on the stack segment.
A far CALL is a call to a procedure which is in a different segment from that which
contains the CALL instruction. When the 8086 executes the far CALL it decrements the
stack pointer by two and copies the content of the CS register to the stack. It then
decrements the stack pointer by two again and copies the offset of the instruction after
CALL to the stack. Finally, it loads CS with the segment base of the code which contains
the procedure and IP with the offset of the instruction of the procedure in that segment.
RET Operation
You may have a question how a program will return back to its previous instruction after
finishing a procedure block after the instruction CALL in the calling program. The answer
to this is by the help of an instruction RET which exactly does the opposite task of the
CALL. If the procedure is a near procedure, (in the same code segment as in the CALL
instruction) then the return will be done by replacing the instruction pointer with a word
from the top of the stack.
If the procedure is a far procedure (in a different code segment from the CALL instruction
which calls it), then the instruction pointer will be replaced by the word at the top of the
stack. The stack pointer will then be incremented by two. The code segment register is
then replaced with a word from the new top of the stack. After the code segment word is
popped off the stack, the stack pointer is again incremented by two. These words/ word
are the offset of the next instruction after CALL. So 8086 will fetch the next instruction
after the CALL.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 12 of 38
8086 Assembly Language Programming and Instruction Sets
MOV BX, 67F2H ; Load the immediate number 67F2H in the BX register
MOV CL, [375AH] ; Copy the contents of the memory location, at a displacement of 375AH
; from the data segment into the CL register
MOV [734AH], BX ; Copy the contents of the BX register to two memory locations in the
; data segment. Copy the contents of the BL register to memory location
; at displacement of 734AH and the content of the BH register into the
; memory in the data segment at the displacement 734BH
MOV DS, CX ; Copy a word from the CX register into the data segment register
MOV TOTAL [BP], ; Copy AX to two memory locations. AL into the first and AH into the
AX ; second. The EA is represented by TOTAL and contents of BP.
; Physical address=EA+SS
MOV CS: TOTAL ; same as the above immediate instruction except the physical
[BP], AX ; address=EA+CS, because the segment override prefix is CS
After the execution of the above instruction, the SP=0032 and this is the top of the stack.
PUSHF
This instruction pushes the flag register contents onto the stack. Whenever this command
is executed the most significant byte of flag register moves into the stack segment memory
location addressed by SP-1. The least significant bytes moves into the memory location SP-
2.
POP destination
This instruction copies a word from the stack location pointed by the stack pointer to the
memory location. After the word copied the stack pointer is automatically incremented by
2. Whenever data is removed from a stack, the data addressed at SP moves into the most
significant byte of the destination register and the byte from the stack segment memory
addressed by SP+1 moves into the least significant byte of the destination register.
Example
POP CX ; Copy a word from top of stack to CX and increment
SP by 2
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 14 of 38
8086 Assembly Language Programming and Instruction Sets
POPF
Removes word from top of stack to the flag register.
Initializing the stack
Before going to use any instruction which uses stack for its operation we have to initialize
stack segment and we have to reverse the memory area required for the stack. The stack
can be initialized by including the following sequence of instructions in the program.
Method 1
ASSUME CS: CODE, DS: DATA, SS: STACK
STACK SEGMENT ; Starts stack segment
S_DATA DB 100 DUP (?) ; fixes the stack data to be 100 bytes (DB is a
;directive for byte and DUP is Generate Duplicate
STACK ENDS
Method 2
Syntax: .Stack [size]
Example: .Stack 100
The .stack is a directive which provides shortcut in definition of the stack segment. The
default segment is 1024.
• LEA
• LDS
• LES
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 15 of 38
8086 Assembly Language Programming and Instruction Sets
This instruction determines the offset of the variable or memory location named as the
source and loads this address in the specified 16-bit register. This instruction does not the
affect flag register.
Example:
Meaning:- load the specified register and DS with words from memory. This instruction
copies a word from two memory locations to the specified register and copies the next two
bytes to the DS.
Example:
LDS CX, [3218H] ; Copy the content of memory location at the specified location
; (3218H and 3219H) into CL and CH and the content of the
; 321AH and 321BH into the DS register
LES Instruction:
Syntax: LES Register, Immediate Register address this instruction does operate exactly as
the LDS however loads the ES register instead of the DS.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 16 of 38
8086 Assembly Language Programming and Instruction Sets
LODS/LODSB/LODSW
This instruction copies a byte from a string location pointed to by SI to AL, or a word from a
string location pointed by SI into AX. LODS does not affect any flags.
STOS/STOSB/STOSW
These instructions copy a byte from AL or a word from AX to a location in the extra
segment. DI is the offset storage that is used to give the location of the memory where the
byte or word is going to be written.
3.2.1.5 Miscellaneous Data Transfer Instructions
This group contains the following instructions.
▪ XCHG
▪ LAHF
▪ SAHF
▪ XLAT
▪ IN and OUT
XCHG Instruction
Example
XCHG AL, SUM [BX] ; exchange bytes in AL with the byte in memory
; at EA=SUM+[BX]
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 17 of 38
8086 Assembly Language Programming and Instruction Sets
This instruction copies the contents of the lower byte of 8086 flag register to AH register.
SAHF INSTRUCTION: Meaning---copy AH register content to the lower byte of the flag
register
This instruction copies the content of the AH register into the lower bytes of the flag register
The XLAT instruction replaces a byte in AL register with a byte from a lookup table in
memory. BX register stores the offset of the starting address of the lookup table and AL
register stores the byte number from the lookup table.
AL [BX+AL]
These two instructions are used to access ports of the 8086. IN is used to input data from
the port address specified byte address in IN. The instruction OUT is used to send data to a
port specified by the address in the instruction itself. There are two basic port addressing
modes related to these instructions. These are direct and indirect port addressing modes.
In direct port addressing mode the port address is readily provided in the instruction while
in indirect it is a content of the specified register that will give out the address of the port in
mind.
Example
INC Instruction:
Syntax Increment destination
This instruction increment the value in the destination by one (adds one to the content of
the specified destination). The destination could be a memory location, or a register. This
instruction affects the flags AF, OF, PF, SF and ZF flags.
Examples:
INC AL
AL AL + 1
INC BX
BX BX + 1
INC WORD PTR [BX] ; Increment word at offset BX in DS.
▪ SUB: subtraction
▪ SBB: Subtraction with borrow
▪ DEC: Decrement (Subtract one)
▪ NEG: 2’s Complement of a number
SUB/SBB Instructions:
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 19 of 38
8086 Assembly Language Programming and Instruction Sets
This instruction subtracts one (1) from the specified destination. The destination may be a
register or a memory location. The flags affected by this instruction are AF, OF, PF, SF, and
ZF.
DEC AL
AL AL - 1
DEC BX
BX BX - 1
DEC WORD PTR [BX] ; Decrement a word at offset BX in the DS
This instruction replaces the number in the destination with the 2’s complement of that
number. The destination can be a register or a memory location.
This instruction can be implemented by inverting each bit and adding 1 to the inversion.
This instruction affects the flags AF, CF, SF, PF, ZF and OF.
This instruction multiplies the unsigned number in the source with the number in AL or
AX. Remember that the register AX is used as an accumulator. When a word is multiplied
by the content of AX, the most significant word of result is stored in DX and least
significant word of the result is stored in AX. MUL affects the flags AF, PF, SF and ZF.
This instruction multiplies the signed number in the source with the number in AL or AX.
When a word is multiplied by the content of AX, the most significant word of result is
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 20 of 38
8086 Assembly Language Programming and Instruction Sets
stored in DX and least significant word of the result is stored in AX. MUL affects the flags
AF, PF, SF and ZF.
If the upper byte of the 16-bit result or upper word of 32-bit result contains only copies of
the sign bit (all 0’s or all 1’s), then the CF and the OF flags will both be 0’s.
3.2.2.4 Division
This group contains the
• DIV
• IDIV
DIV Instruction:
When a double word is divided by a word, the most significant word of the double word
must be in DX and the least significant word must be in AX. After the division the AX will
contain a 16-bit quotient and the DX a 16-bit remainder.
If dividing of a byte by a byte is desired it is important to put the byte in AL and pad AH
with all zeroes. The following example demonstrates how binary division is carried out.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 21 of 38
8086 Assembly Language Programming and Instruction Sets
Example
3.2.2.5 Comparison
Syntax CMP Destination, Source
The comparison instruction (CMP) compares a byte/word from specified source with a
byte/word from the specified destination. The source and destination must both be a byte
or word. The source could be an immediate number, a register, or a memory location. The
destination can be a register or a memory location, but both the destination and the source
cannot be memory places at the same time. The comparison is done by subtracting the
source byte or word from the destination byte or word. The result is not stored in the
destination. Rather only the flag registers are affected. Both the source and the destination
remain unchanged. The flags updated include,
The flags affected are AF, OF, SF, ZF, PF, and CF
Segment registers are not comparable; therefore the register cannot be the segment
registers
Examples
CMP BL, 01H ; compare an immediate number 01H with byte in BL
CMP CX, BX ; compare word in BX with word in CX
CMP CX, TOTAL ; compare word at the displacement TOTAL in DS with the
; word in CX
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 22 of 38
8086 Assembly Language Programming and Instruction Sets
This sub instruction set contains two instructions. They are DAA (Decimal Adjust After
Addition) and DAS (Decimal Adjust after Subtraction). Both are used to adjust the results
after the specific operation.
DAA Instruction
This instruction is used to make sure the result of adding two packed BCD numbers is
adjustable to be a formal BCD number. To demonstrate the function of this instruction let
us pay attention to the following example,
1001 + 1000 = 10001
9 + 8 = 17
The sum of the two binary numbers has just generated another binary number of five bits.
This is not any of the BCD format. We here understand that addition of BCDs may results
into non-BCD format that has to be re-arranged into BCD again. (Note that 10001 is not 17
in BCD). This sum can be corrected and changed into BCD by adding 6 in binary to the
sum calculated.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 23 of 38
8086 Assembly Language Programming and Instruction Sets
Adjusting of the BCD sum into BCD in 8086 can be achieved using the following algorithm.
1. If the lower order four bits (D3-D0) in AL is greater than 9 or if AF is set the
instruction adds 6 (06) to the low order four bits.
2. If the value of the high-order four bits (D7-D4) in the AL is greater than 9 or if
carry flag is set, the instruction adds 6 (60) to the high-order four bits.
Example
This instruction updates the AF, CF, PF, and ZF. The OF is understand after DAA. Note
that the instruction DAA only works for AL (Register A)
The instruction is used after subtracting packed BCD numbers to make sure the result is
correct packed BCD.
1. If the lower order four bits (D3-D0) in AL is greater than 9 or if AF is set the
instruction subtracts 6 (06) to the low order four bits.
2. If the value of the high-order four bits (D7-D4) in the AL is greater than 9 or if
carry flag is set, the instruction subtracts 6 (60) to the high-order four bits.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 24 of 38
8086 Assembly Language Programming and Instruction Sets
The DAS instruction updates the AF, CF, PF, and ZF. The OF flag is unaffected after DAS
instruction. The same was as DAA, DAS only affects the AL register.
The numbers from 0-9 are represented as 30H-39H in ASCII code. Whenever adding of two
numbers is necessary in ASCII code, it is important to mask upper nibble (3) from the code
before addition.
register or a memory location. The flags affected include PF, SF and ZF. Both CF and OF
are zero after AND operation.
; AL=0011 1001 = 39 H
; CL=0001 0010 = 12 H
AND AL, CL ; AL=0001 0000 = 10 H
One of the most important application of the AND operations is masking. In masking we
clear bits. Any value AND ed with zero is zero.
3.2.3.2 OR Instructions
It is known that OR operation produces logic 1 whenever one of the two inputs is one.
broadly speaking if any one of the inputs to an OR gate is one, then the output will be one.
X Y Z
0 0 0
0 1 1
1 0 1
1 1 1
Table 2 Truth Table for OR gate
The instruction OR logically ORs all bits in the destination with bits in the source and
stores the result in the destination. The source may be an immediate number, a register or
a memory location. The destination can only be a memory location or a register.
; AL=0011 1001 = 39 H
; CL=0001 0010 = 12 H
OR AL, CL ; AL=0011 1011 = 3B H
The OR instruction has a special function. It is used to set bits. Remember that any bit
ORed with one is one. Flags affected are PF, SF and ZF. Both CF and OF are both 0 after
OR instruction.
X Y Z
0 0 0
0 1 1
1 0 1
1 1 0
The source may be an immediate number, a register or a memory location. The destination
may be a register or a memory location. Flags affected are PF, SF and ZF. Both CF and OF
are both 0 after OR instruction.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 26 of 38
8086 Assembly Language Programming and Instruction Sets
; AL=0011 1001 = 39 H
; CL=0001 0010 = 12 H
XOR AL, CL ; AL=0010 1011 = 2B H
XOR instruction has a special function. If an unknown number is XORed with all ones it
gives all toggled bits. Therefore XOR is used to toggle even unknown values.
NOT Instruction:
Syntax: NOT Destination
The NOT inverts each bit of a byte or a word. The destination can be register or a memory
location.
; AL=0011 1001 = 39 H
NOT AL ; AL=1100 0110 = C6 H
NOT does not affect any flags
Refer the following topics from Microprocessors and Interfacing, first Edition, 2009. A.P Douglas and
D.A Douglas page 3-32 to 3-50
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 27 of 38
8086 Assembly Language Programming and Instruction Sets
• Specify the problem: this is a point at which the programmer understands the
problem and decides what is to be done. This is the most important step that is used
to initiate the next steps.
• Designing the solution for the problem: this step involves coming up with the exact
step by step procedure that must be followed in order to come up with the solution.
The design of the same program could vary. This step requires designing and writing
down of the designs.
• Coding: once the problem is specified and designed, the next step would be coding
the design. Coding is also known as implementing the problem. Coding is telling the
processor what to do in which order. This requires skill so that the programmer may
select appropriate instructions to do the task. Coding for the same design could vary
depending on the experience and knowledge of the coder.
• Debugging: once the program is developed and implemented (coded), the next step is
debugging the code. Debugging is the process of testing the code if it does exactly
what it is supposed to according to the design procedure. During this process errors
are found and fixed.
There is a conventional way of providing what to be done. This is known as flow charts.
Flow charts give the actions to be performed in step by step fashion. This is a graphical way
of representing the actions.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 28 of 38
8086 Assembly Language Programming and Instruction Sets
There are important steps in coming up with a 100 percent functional program. This
involves understanding the various types of languages that machines (microprocessors)
understand. Even though there are high level programs that can take the filthy works of
assembling and linking, understanding the assembler language brings in great
understanding how processors work. A program which has simply a sequence of binary
coeds for an instruction is called machine level language program. This takes a name
machine language just because it is made up of series of zeroes and ones that machines
directly understand. However, writing machine language for humans is extremely
complicated. Therefore, there must be another way of presenting these codes to humans by
compromising the level the machines understand it. Getting one more stage above the
machine language is the assembly language. The assembly language is relatively much
easier for a programmer to understand and write. We have already studied instructions in
their assembly form. AND is one of these. However, it is important to note that the
instructions AND shall finally be converted in its machine equivalent (zeroes and one). In
assembly language we have opcodes or mnemonics that represent the specific zeroes and
ones in machine languages.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 29 of 38
8086 Assembly Language Programming and Instruction Sets
A mnemonic is an instruction itself. An instruction could address one or two operands. The
comment is an optional field used to indicate what exactly the code does. The mnemonic
generate the control signals while when the operands are data to be processed.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 30 of 38
8086 Assembly Language Programming and Instruction Sets
• Come up with a minimum solution to the problem: this is very important as there
is a requirement of memory spaces. Minimum code requires less memory and is
highly preferable. The design should come up with the minimum solution for the
problem.
• Use proper instruction and advanced instructions: there are more than one set of
instructions that do the same task. Going from one instruction to the other should be
based on the fact that it results in better performance for the intended application
rather than a programmer being familiar with it. Therefore, knowledge of instructions
and instruction sets is mandatory. Here falls addressing modes too. Remember that
addressing modes can indirectly specify the type of the data and addressing modes
result in different execution clock cycle for the instruction which directly affects the
performance of the program. For example, the following explains two possible ways of
implementing a code for moving blocks of data from one place to another.
One can see that the second approach requires less number of instructions and is
therefore more efficient, meaning that it occupies less amount of memory space.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 31 of 38
8086 Assembly Language Programming and Instruction Sets
An assembler translates a source file that was created using the editor into machine
language such as binary or object code. The assembler usually produces two different types
of files. The one is called the object file and the other assembler list file. The object file
contains the binary code for the instructions and the information the addresses of the
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 32 of 38
8086 Assembly Language Programming and Instruction Sets
instructions. The list file contains the assembly language statements, the binary code for
each instruction, and the offset for each instruction. The following figure illustrates this.
Linking is a process of joining several object files into single larger object file. Linking aids
in designing one big program. Usually programs can be developed separately in a logical
fashion and linked together to form one large program. A set of instruction which does one
specific task is designed and separately saved. When there is a need to use the module, one
can easily call the routine and add it into the code. The linker process produces a link file
that contains the binary codes for all the combined modules. The linker also produces a
map which contains the address information about the linked files. The linker however,
does not assign absolute addresses to the program; it only assigns relative addresses
starting from zero. This kind of program is said to be re-locatable because it can be placed
anywhere in the memory.
Debugging a program requires loading the object file of the program into the memory of the
target processor and executes it to see if it is possible to come up with the desired output. A
debugger is usually a software program or a hardware kit. In case of software applications,
the debugger stands on the behalf of the processor and simulates it fully. Debugger
software allow you to
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 33 of 38
8086 Assembly Language Programming and Instruction Sets
1. To look into the contents of register and memory locations after the program runs
2. Allows the users to change the content of registers and memory locations
3. Some debuggers allow users to execute sets of instructions step by step
4. Allows users to set breakpoints and execute lines up to the points.
In this section we shall see the possible ways of providing delays in 8086. All are software
delays
There is a special instruction in 8086 that does nothing. This instruction is NOP
instruction. It is a mnemonic for no operation. 8086 requires 3 clock cycles to finish
executing NOP. Therefore one can at least get three clock cycles by executing it in between
two instructions.
Another way to delay a processor is by making it count up to certain desired number. One
should load the number to be loaded onto the CX register so that counting it will produce
the desired amount of delay in the program. Look at the following example
= 2692 cycles
If the processor is running on 10 MHz, we see that one clock frequency is 0.1µsec, therefore
using the above routine one can get 269.2µseconds.
In this approach once or more external loop is added to execute the internal loop multiple
times so that we can get larger delays. The inner loop is nothing but the program we have
seen in the above immediate section.
For count = 150 and multiplier=50, the number of clock cycles required are,
= 134600 cycles
If the processor is running on 10 MHz, we see that one clock frequency is 1µsec; therefore
using the above routine one can get 13.46ms.
Exercise: Write an 8086 ALP to generate a delay of 100ms, if the processor is running
on 10 MHz frequency.
8086 can be configured to work in two different modes. These are minimum and maximum
modes. In minimum mode, the processor is alone and is required to take care of all the
coordination. In maximum mode, two or more processors work in conjunction to each other
and therefore must have another third party to coordinate them. The minimum mode is
often used for small systems and the maximum mode for larger tasks requiring complex
systems. There is no literal physical difference between the two modes. There difference is
only setting of the MN/MX (MX bar). Let us see the special pins that will affect the mode in
8086.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 36 of 38
8086 Assembly Language Programming and Instruction Sets
4 DT/R (Data transmit/Receive) Output: this controls the data flow direction.
High on this pin indicates that the processor is transmitting while the low is for
receiving.
5 M/IO Output: is used to differentiate between memory (M/IO=HIGH) or IO
(M/IO=LOW) data transfer.
6 WR: Write Output: when 8086 writes data to either external IO or memory device
this pin goes LOW.
7 HOLD input, HLDA Output: A HIGH on HOLD pin indicates that another master
(DMA) is requesting to take over the system bus. When a HOLD is received the
processor outputs HLDA signal HIGH as an acknowledgement. At the same time
the processor tristates the system bus. A LOW on HOLD gives the system bus
control back to the processor. Processor then output LOW signal on HLDA.
2 S2, S1, So (Active Low) (outputs): these three status signals indicate the type of
transfer to take place during the current bus cycle.
S2 S1 So Machine Cycle
Interrupt
0 0 0
Acknowledge
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Instruction fetch
1 0 1 Memory Read
1 1 0 Memory Write
1 1 1 Inactive-Passive
3 LOCK (Active Low): signifies that an instruction with a LOCK prefix is being
executed and the bus is not to be used by any other processor.
4 RQ/GT1 and RQ/GT0 (Active Low) in the maximum mode, HOLD and HLDA pins
are replaced by the RQ (Bus Request) and GT0 (Bus Grant), and RQ/GT1 signals.
By using bus request, another master can request for the system bus and
processor communicate that the request is granted to the requesting master by
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 37 of 38
8086 Assembly Language Programming and Instruction Sets
using bus granted signals. Both signals are similar except the RQ/GT0 has higher
priority than RQ/GT1.
Arba Minch Institute of Technology, Faculty of Electrical & Computer Engineering Page 38 of 38