Study of 8086
Study of 8086
Features of 8086:
Data bus : 16 bit
Address bus 20 bit . so, memory that can be addressed : 1 Mbytes ( 1048576 bytes exactly)
Total no. of registers available for programmer :14
Addressing modes: 24
Clock rates : 8086 = 5 MHz , 8086-1 = 8 MHz , 8086 -2 = 10 MHz
40 DIP
Technology : n channel MOSFET ( HMOS)
Can operate in single or multi processor mode.
- The architecture of 8086 supports a 16-bit ALU, a set of 16 – bit registers and provides segmented memory
addressing capacity, a rich instruction set, powerful interrupt structure, prefetched instruction queue for
overlapped fetching and execution .
- The complete architecture 8086 can be divided into two parts
I) Bus Interface Unit (BIU)
II) Execution Unit (EU)
- It contains the ckt for physical address calculations and an instruction byte queue ( 6 bytes long). The bus
interface is available for external interfacing of the devices. In other words, this unit is responsible for
establishing communications with external devices and peripherals including memory via the address and data
bus.
a) Segment Registers
b) Instruction byte queue.
c) Address conversion Mechanism (Adder)
d) Instruction Pointer (IP)
- The 8086 addresses segmented memory . The complete 1MB memory, which the 8086 is able to address, is
divided into 16 logical segments. Each segment thus contains 64kb locations .. There are 4 segment registers :
1) Code segment register (CS)
2) Data segment register (DS)
3) Extra segment register (ES)
4) Stack segment register (SS)
- The code segment register (CS) is used for addressing a memory location in the code segment of the memory
where executable program is stored.
- The data segment register points to the data segment of memory where the data (I/P / O/P) is stored.
- The extra segment register (ES) refers to the segment which essentially is another data segment of memory.
Thus extra segment also contains data.
- The stack segment register (SS) is used for addressing stack segment of memory which is used to store stack
data. The CPU uses stack for temporarily storing data. Such as return addresses, contents of registers before
calling a subroutine.
II ) EU
The register Ax, Bx, Cx, Dx, are the general purpose 16 bit registers. Ax is used as 16-bit accumulator. AL can
be used as an 8 bit accumulator for 8 bit operations.
8 8
AH AL AX
BH BL BX
CH CL CX
DH DL DX
The EU contains pointers except IP. The BP (Base Pointer) ands SP (Stack Pointer) usually contains
offsets within the (code, data) and (stack) segment respectively. The index registers are used as general purpose
registers as well as for offset storage in case of indexed, based indexed and relative base indexed addressing modes.
The register SI is generally used to store the offset of source data in data segment while register DI is used to store
offset of destination in data or extra segment. The index registers are particular for string manipulations.
8086 has 16 bit ALU, able to perform arithmetic and logic operations. The 16 bit flag
register reflects the result of execution by ALU.
D) FLAG REGISTER :
The condition code flag register is lower byte of 16 bit flag register along with overflow flag, which is not present in
8085. This part of flag register of 8086 reflects the results of ALU. The control flag register is higher byte of flag
register of 8086 affect operation of ALU. The control flag register is higher byte of flag. Register of 8086. It
contains 3 flags viz. direction flag of 8086 (D), Interrupt flag (I) & trap flag (T)
• S : Sign flag : Set ,when result of comparison is negative. ( i.e. copy of MSB bit of result.)
• P- Parity flag : Set, when lower byte of result contains even nos of 1’s.
• C- carry flag : Set , when carry is there out of MSB in case of addition or borrow in case of subtraction.
• T – Trap flag : When set , the processor enters the single step execution mode.
• D-Direction flag : Used by string manipulation instructions. If ‘0’ then string is processed from lowest address
to highest address, otherwise highest address to lowest address.
• AC – Auxiliary carry flag : Set if there is a carry instructions from bit 3 during addition or borrow from bit 3
during subtraction.
• O – Overflow flag : Set if overflow occurs, i.e if a result of signed operation is larger /smaller than size of
destination register.
The microprocessor 8086 is 16 bit CPU available in three clock rates. i.e 5,8 & 10 MHz. It is 40 pin DIP
IC. The 8086 operates in single or multiprocessor configuration to achieve high performance.
Hold : if high, indicates to processor that another master is requesting the bus access. The processor after
receiving HOLD request, issues back. Signal on HLDA pin. These are used with DMA controller.
AD19 / S6 to AD16 / S3 :
These are multiplexed address / status lines.
S4 S3 INDICATES
0 0 Alternate data
0 1 Stack
1 0 Code or none
11 1 data
~BHE / S7(O/P) : Bus high enable / status: BHE is used to indicate availability of valid data on the higher data bus D8- D15 .
and status information is available during T2, T3, T4.
BHE A0 INDICATES
0 0 Whole word
0 1 Upper byte or to odd address
1 0 Lower byte or to even address
1 1 none
~RD and ~WR (O/P): These are active low signals . They are used to perform memory or I/O read and write operations
Ready (I/P): (Active high ) If it is low . the processor enters into wait states until assertes high. It is used to put delays so as
to synchronize slower peripherals .
INTR(I/P) and ~ INTA (I/P):
INTR is level triggered i/p . It is sampled during last clock cycle of each instruction cycle to check if an interrupt is pening or
not.
~INTA : The 8086 sends makes this signal low to indicate that it has accepted request .
~TEST (I/P): It is examined when WAIT instruction is executed. . Ie TEST pin is low , execution continues , else 8086
remains in idle state.
ALE : (O/P) Indicates that a valid address is available on AD15-AD8 during T1.
DT/ ~R : (O/P) Dta tranmit / receive : Used to indicate the direction of data flow through transreceiver.
~Lock (O/P) : When low , prevents other bus masters from taking control of system bus .
Addressing modes
Implied - the data value/data address is implicitly associated with the instruction. e.g. STC, HALT, DAA
Register - references the data in a register or in a register pair. E.g. MOV AX, BX
Immediate - the data is provided in the instruction. E.G. MOV AX, 0F63DH
Direct - the instruction operand specifies the memory address where data is located.E.G. MOV AX, [0F36DH]
Register indirect - instruction specifies a register containing an address, where data is located. This addressing mode works
with SI, DI, BX and BP registers.
1)Based - 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. E.G. MOV AX, [BX]
2)Indexed - 8-bit or 16-bit instruction operand is added to the contents of an index register (SI or DI), the resulting value is
a pointer to location where data resides. . MOV AX, [SI]
3)Based Indexed - the contents of a base register (BX or BP) is added to the contents of an index register (SI or DI), the
resulting value is a pointer to location where data resides. E.G. MOV AX, [BX][SI]
4)Based Indexed with displacement - 8-bit or 16-bit instruction operand is added to the contents of a base register (BX or
BP) and index register (SI or DI), the resulting value is a pointer to location where data resides. .
E.G. MOV AX, 73 [BX][SI] , . MOV AX, -1234[BP][SI]
MNEMONIC DESCRIPTION
ARITHMATIC INSTRUCTIONS
Addition instructions:
ADD Add specified byte to byte or specified word to word.
ADC Add byte + byte+ carry flag or word + word + carry flag.
INC Increment specified byte or specified word by 1.
AAA ASCII adjust after addition.
DAA Decimal (BCD) adjust after addition.
Subtraction Instructions :
SUB Subtract byte or word from word.
SBB Subtract byte and carry flag from byte or word .
DEC Decrement specified byte or specified word by 1.
NEG Negate – invert each bit of a specified byet or word and add 1 (form 2’s complement).
CMP Compare two specified bytes or two specified words.
Multiplication instructions:
MUL Multiply unsigned byte by byte or unsigned word by word.
IMUL Multiply signed byte by byte or signed word by word.
AAM ASCII adjust after multiplication.
Division instructions:
DIV Divide unsigned word by byte or unsigned double word by word.
IDIV Divide signed word by byte or signed double word with sign bit of lower word.
AAD ASCII adjust before division.
CBW Fill upper word of double word with sign bit of lower word.
Logical instructions :
NOT Invert each bit of a byte or word.
AND AND each bit in a byte or word with the corresponding bit in another byte or word.
OR OR each bit in a byte or word with the corresponding bit in another byte or word.
XOR Exclusive OR each bit in a byte or word with the corresponding bit in another byte or word.
TEST AND operands to update flags, but don’t change operands.
Shift instructions :
SHL / SAL Shift bits of word or byte left, put zero (s) in LSB (s).
SHR Shift bits of word or byte right, put zero (s) in MSB (s).
SAR Shift bits of word or byte right, copy old MSB into new MSB.
Rotate Instructions :
ROL Rotate bits of byte or word left, MSB to LSB and to CF.
ROR Rotate bits of byte or word right, LSB to MSB and to CF.
RCL Rotate bits of byte or word left, MSB to CF and cF to LSB.
RCR Rotate bits of byte or word right, LSB to CF and CF to MSB.
STRING OPERATIONS
A string is a series of bytes or a series of words in sequential memory locations. A string often
consists of ASCII character codes. In the list, a “/ ” is used to separate different mnemonics
for the same instruction. Use the mnemonic which most clearly describes the function of the
instruction in a specific application. A “B” in a mnemonic is used to specifically indicate that a
string of words is to be acted upon.
REP An instruction prefix Repeat following instruction until CX = 0
REPE / REPZ An instruction prefix Repeat instruction until CX = 0 or zero flag ZF 1.
REPNE / REPNZ An instruction prefix Repeat until CX = 0 or ZF = 1.
MOVS / MOVSB/ MOVSW Move byte or word from one string to another.
COMPS/COMPSB/CMPSW Compare two string bytes or two string words.
SCAS/SCASB/SCASW Scan a string. Compare a string byte with a byte in AL or a string word with a
word in AX.
LODS/LODSB/LODSW Load string byte into AL or string word into AX.
STOS/STOSB/STOSW Store byte from AL or word from AX into string.
Interrupt instructions :
NT Interrupt program execution, call service procedure.
INTO Interrupt program execution if OF = 1.
IRET Return from interrupt service procedure to main program.
Pin diagram :