You are on page 1of 30

8086

&
8088
Internal
block
diagram
of
8086
Flag register of 8086
Memory
organisation
in 8086
8086 BASED
COMPUTER
SYSTEM
IN
MINIMUM
MODE
8086 BASED
COMPUTER
SYSTEM IN
MAXIMUM
MODE
Addressing modes in 8086
• Immediate addressing mode: MOV CX, 4929 H, ADD AX, 2387 H, MOV AL, FFH
• Register addressing mode: MOV CX, AX ; ADD BX, AX
• Direct addressing mode: MOV AX, [1592H], MOV AL, [0300H]
• Register indirect addressing mode: MOV AX, [BX] ADD CX, {BX}
• Based addressing mode: MOV DX, [BX+04], ADD CL, [BX+08]
• Indexed addressing mode: MOV BX, [SI+16], ADD AL, [DI+16]
• Based-index addressing mode: ADD CX, [AX+SI], MOV AX, [AX+DI]
• Based indexed with displacement mode: MOV AX, [BX+DI+08], ADD CX, [BX+SI+16]
Instruction set of 8086 microprocessor

Types of instructions:

• Data Transfer Instructions


• Arithmetic Instructions
• Bit Manipulation Instructions
• String Instructions
• Program Execution Transfer Instructions (Branch & Loop Instructions)
• Processor Control Instructions
• Iteration Control Instructions
• Interrupt Instructions
MOV Instructions
Instruction Operands

MOV reg, Memory MOV AX, [3000]


memory, reg
reg, reg MOV AL,CL
memory, immediate MOV [3000], 34h
reg, immediate
sreg, memory
memory, sreg
reg, sreg
sreg, reg
LOAD and STORE
• LODSB • IN
• LODSW • OUT

• STOSB
• STOSW
• PUSH
• POP
Arithmetic Instructions
ADD [BX+SI+06],34H; BX=2000H;SI=1001
3001H
Instructions to perform addition
• ADD − Used to add the provided byte to byte/word to word.
• ADC − Used to add with carry.
• INC − Used to increment the provided byte/word by 1.
• AAA − Used to adjust ASCII after addition.
• DAA − Used to adjust the decimal after the addition operation
Instructions to perform subtraction

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


• SBB − Used to perform subtraction with borrow.
• DEC − Used to decrement the provided byte/word by 1.
• NPG − Used to negate each bit of the provided byte/word and add 1/2’s
complement.
• CMP − Used to compare 2 provided byte/word.
• AAS − Used to adjust ASCII codes after subtraction.
• DAS − Used to adjust decimal after subtraction
Instruction to perform multiplication

• MUL − Used to multiply unsigned byte by byte/word by word.


• IMUL − Used to multiply signed byte by byte/word by word.
• AAM − 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.
 IDIV − Used to divide the signed word by byte or signed double word by
word.
 AAD − Used to adjust ASCII codes after division.
Compare & Logical instructions
 CMP AX/AL, 8bit/16bit data  NOT mem/reg
 CMP mem/reg, data
 CMP mem/reg, mem/reg  TEST AX/AL, 8bit/16bit data
 AND AX/AL, 8bit/16bit data  TEST mem/reg, data
 AND mem/reg, data  TEST mem/reg, mem/reg
 AND mem/reg, mem/reg
 OR AX/AL, 8bit/16bit data
 OR mem/reg, data
 OR mem/reg, mem/reg

 XOR AX/AL, 8bit/16bit data


 XOR mem/reg, data
 XOR mem/reg, mem/reg
Rotate instructions

rotates all bits in X to


ROR X, Y ROR BL, CL
the right Y times
rotates all bits in X to
ROL X, Y ROL BX, 06
the left Y times
rotates all bits in X to
RCR X, Y the right along with RCR BL, CL
carry flag Y times
rotates all bits in X to
RCL X, Y the left along with carry RCL BX, 06
flag Y times
SHIFT Inst
SAL CX, 1 ; shift bits in CX 1-bit left; puts 0 in LSB and MSB in CF
SHL AX, CL ; Left shift bits in AX for 5 times (assume CL = 05H); puts 0's in 5 LSB's and last MSB in CF

SAR CX, 1 ; shift bits in CX 1-bit right; puts copy of old MSB in MSB and LSB in CF
SAR AX, CL ; Right shift bits in AX for 5 times (assume CL = 05H); puts 5 old MSB in 5 MSB's portion
SHR CX, 1 ; shift bits in CX 1-bit right; puts 0 in MSB and LSB in CF

SHR AX, CL ; Right shift bits in AX for 5 times (assume CL = 05H); puts 0's in 5 MSB's and last LSB in CF
Testing Instructions Operation Testing Condition
Instructions Operation
Condition
Jump if Less Than/Jump if Not
Jump if Above/Not Below or JL/JNGE (S xor O)=1
JA/JNBE C=0 and Z=0 Greater Than or Equal
Equal
Jump if Less than or Equal/Jump
JLE/JNG ((S xor O) or Z) = 1
Jump if Above or Equal/ Jump if Not Greater
JAE/JNB/JNC C=0 Jump if Not Equal/ Jump if Not
if Not Below/Jump if No Carry JNE/JNZ Z=0
Zero
Jump if Below/ Jump if Not Jump if Not Parity/Jump if
JB/JNAE C=1 JNP/JPO P=0
Above or Equal Parity Odd
Jump if Below or Equal/ Jump Jump if Not Signed/Jump if
JBE/JNA (C or Z) =1 JNS S=0
if Not Above Positive
JC Jump if Carry C=1 JO Jump if Overflow O=1
JNO Jump if Not Overflow O=0
JNC Jump if Not Carry C=0
Jump if Parity/ Jump if Parity
JP/JPE P=1
JCXZ Jump if the CX register=0 CX=0 Even
Jump if Signed/ Jump if
JE/JZ Jump if Equal/Jump if Zero Z=1 JS S=1
Negative
Jump if Greater/Jump if Not ((S xor O) or Z)
JG/JNLE JMP address 1890: JMP displacement 16 bit(unsigned)
Less Than or Equal =0
Jump if Greater or Equal/Jump JMP memory/reg JMP displacement 8 bit(signed)
JGE/JNL (S xor O)=0
if Not Less Than
CALL and RET instruction
• CALL address CALL 6755H RET
• CALL mem CALL displacement 16 RET displacement 16
bit(unsigned)
IRET
• CALL mem/reg [ indirect addressing]
• CALL [6755H]
Interrupts and Interrupt Routines: The process of interrupting
the normal program execution to carry out a specific task/work is
referred to as interrupt.
The process of interrupting the normal program execution to carry out a specific
task/work is referred to as interrupt.
The processor can be interrupted in the following ways
i) by an external signal generated by a peripheral,
ii) by an internal signal generated by a special instruction in the program,
iii) by an internal signal generated due to an exceptional condition which occurs
while executing an instruction. (For example, divide by zero in 8086 initiates type 0
interrupt)
Classification of Interrupts

In general the interrupts can be classified in the following three ways:

1.Hardware and software interrupts


2.Vectored and Non Vectored interrupt:
3.Maskable and Non-Maskable interrupts.
Hardware and software interrupts

• Hardware interrupts are initiated by external hardware by sending an


appropriate signal to the interrupt pin of the processor. The 8086 processor
has two interrupt pins INTR and NMI.
• Software interrupts are program instructions. The 8086 processor has 256
types of software interrupts. The software interrupt instruction is INT n,
where n is the type number in the range 0 to 255.
Vectored and Non Vectored interrupt:

• When an interrupt signal is accepted by the processor, if the program


control automatically branches to a specific address (called vector address)
then the interrupt is called vectored interrupt.
Maskable and Non-Maskable interrupts.
The processor has the facility for accepting or rejecting hardware interrupts.
Programming the processor to reject an interrupt is referred to as masking or
disabling and programming the processor to accept an interrupt is referred to as
unmasking or enabling.
• The interrupts whose request can be either accepted or rejected by the
processor are called maskable interrupts.
• The interrupts whose request has to be definitely accepted (or cannot be
rejected) by the processor are called non-maskable interrupts.
Interrupts in 8086
• INT n
where n = 0 to 255
• INTO
multiply two 8 bit numbers

MOV SI, 5000 set 5000 to SI


MOV DI, 6000 set 6000 to DI
MOV AL, [SI] load contents of offset SI to register AL
INC SI increase value of SI by 1
MOV CL, [SI] load contents of offset SI to register BL
MUL CL multiply contents of register AL and BL
MOV [DI], AX store the result (contents of register AX) to offset DI
HLT End.
multiply two 16 bit numbers

2000 MOV AX, [3000] [AX] <- [3000]


2004 MOV BX, [3002] [BX] <- [3002]
2008 MUL BX [AX] <- [AX] * [BX]
200A MOV [3004], AX [3004] <- AX
200E MOV AX, DX [AX] <- [DX]
2010 MOV [3006], AX [3006] <- AX
2014 HLT Stop
largest number in an array of n
numbers(8bit/16bit)
MOV SI, 5000 : set the value of SI to 5000
CMP AX, [SI] : compares value of register AL and [SI] (AL-[SI])
JAE GO : jump to address 413 if carry not generated
MOV AX, [SI] : transfer data at offset SI to register AL
GO: LOOP BACK : decrease value of register CX by 1 and jump to
address 40D if value of register CX is not zero
MOV [6000], AL : store the value of register AL to offset 600
HLT : stop

You might also like