Professional Documents
Culture Documents
Microprocessors and Microcontrollers: Unit II Instruction Set and Assembly Language Programming of 8086
Microprocessors and Microcontrollers: Unit II Instruction Set and Assembly Language Programming of 8086
Unit II
Instruction Set and
Assembly Language Programming of 8086:
Part 3
B.Tech, ETM,
II Year, II Semester
N.Ramakrishna
Dept. of Electronics and Telematics
GNITS, Hyderabad
April 16, 2022 MPMC-N.Ramakrishna Unit II Part 3 1
Syllabus
Unit II
Instruction Set and
Assembly Language Programming of 8086:
• Instruction formats
• Addressing modes
• Instruction set
• Assembler directives
• Macros
• Simple programs involving logical, branch and
call instructions, sorting,
evaluating arithmetic expressions,
string manipulations.
Register Register
Destination
Register Memory
Memory Register Register
Register Immediate Memory
Memory Immediate
Accumulator Immediate
April 16, 2022 MPMC-N.Ramakrishna Unit II Part 3 4
Logical Instructions
AND
• Uses any addressing mode except memory-to-memory and
segment registers
• Especially used in clearing certain bits (masking)
XXXX XXXX
AND 0 0 0 0 1 1 1 1
= 0 0 0 0 XXXX (clear the first four bits)
Examples: AND BL, 0FH;
AND AL, [0345H];
OR
• Used in setting certain bits
XXXX XXXX
OR 0 0 0 0 1 1 1 1
= XXXX 1 1 1 1 (Set the lower four bits)
0
CF
CF
Destination Count
Register Immediate
Register CL
Memory Immediate
Memory CL
0
CF
• Operand types:
SHL reg,imm8
SHL mem,imm8
SHL reg,CL
SHL mem,CL
April 16, 2022 MPMC-N.Ramakrishna Unit II Part 3 12
Fast Multiplication
Ex.
; Multiply AX by 10
SHL AX,1 ; multiply AX by 2
MOV BX, AX ; copy AX to BX
MOV CL,2 ; copy 2 to CL (count)
SHL AX,CL ; multiply AX by 4
ADD AX, BX ; Add AX and BX to
get 10 AX
0
CF
CF
MOV DL,-80
SAR DL,1 ; DL = -40
SAR DL,2 ; DL = -10
CF
CLC ; CF = 0
MOV BL,88H ; CF,BL = 0 10001000b
RCL BL,1 ; CF,BL = 1 00010000b
RCL BL,1 ; CF,BL = 0 00100001b
April 16, 2022 MPMC-N.Ramakrishna Unit II Part 3 19
ROR Instruction
• ROR (rotate right) shifts each bit to the right
• The lowest bit is copied into both the Carry flag and
into the highest bit
• No bits are lost
CF
MOV AL,11110000b
ROR AL,1 ; AL = 01111000b
MOV DL,3Fh
ROR DL,4 ; DL = F3h
April 16, 2022 MPMC-N.Ramakrishna Unit II Part 3 20
RCR Instruction
• RCR (rotate carry right) shifts each bit to the right
• Copies the Carry flag to the most significant bit
• Copies the least significant bit to the Carry flag
CF
STC ; CF = 1
MOV AH,10H ; AH,CF = 00010000 1
RCR AH,1 ; AH,CF = 10001000 0
Register Immediate
Register CL
Memory Immediate
Memory CL
CMP Compare CMP D,S (D) – (S) is used CF, AF, OF,
in setting or resetting PF, SF, ZF
the flags
Allowed Operands
Destination Source
Condition ZF CF SF
Register Register
(D) = (S) 1 0 0
Register Memory
(D) > (S) 0 0 0
Memory Register
(D) < (S) 0 1 1
Register Immediate
Memory Immediate
Accumulator Immediate
April 16, 2022 MPMC-N.Ramakrishna 24
String