0% found this document useful (0 votes)
9 views102 pages

8086 Microprocessor Lab Guide

The document outlines the objectives and content of a microprocessor lab course, focusing on the 8086 microprocessor. It covers various instructions including MOV, ADD, SUB, MUL, DIV, AND, and OR, along with examples and homework assignments for practical application. The document is structured into lectures that aim to teach students about registers, instruction syntax, and programming exercises.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views102 pages

8086 Microprocessor Lab Guide

The document outlines the objectives and content of a microprocessor lab course, focusing on the 8086 microprocessor. It covers various instructions including MOV, ADD, SUB, MUL, DIV, AND, and OR, along with examples and homework assignments for practical application. The document is structured into lectures that aim to teach students about registers, instruction syntax, and programming exercises.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ministry of Higher Education ‫جمهوريـ ـ ـة الع ـ ـ ـراق‬

& Scientific Research ‫العلم‬ ‫العال والبحث‬ ‫وزارة التعليم‬


‫ي‬ ‫ي‬
Sumer University-Engineering College ‫جامعة سومر –كلية الهندسة‬
Department of communication engineer ‫قسم هندسة االتصاالت‬
3rd Stage ‫الم ـ ــرحل ـ ـ ـ ـ ـ ـ ــة ال ـ ـ ــثالثـة‬

Microprocessor (lab)
Dr. Yasser Kareem Hummadi
Asst. lecturer. Elaf Noori Saddam
Lecture objectives
The student will recognize the following objectives

1. Know the types of Registers


in 8086 Microprocessor.
2. MOV Instruction.
8086 Microprocessor

Registers

General Purpose Special Purpose Segment Instruction


Registers Registers Registers Pointer

AX SP CS 1. IP
BX BP DS
CX SI ES
DX DI SS
General Purpose Registers
AX= 16 bits

AH= 8 bits 1. AX
AL==8 AH
bits + AL
15 8 7 0
Accumulator Register

BX= 16 bits

BH= 8 bits BL= 8 bits


15 8 7 0
2. BX = BH + BL

Base Register
General Purpose Registers
CX= 16 bits

3. CX = CH + CL CH= 8 bits CL= 8 bits


15 8 7 0
Counter Register

DX= 16 bits

DH= 8 bits DL= 8 bits


15 8 7 0
4. DX = DH + DL

Data Register
Special Purpose Registers
SP= 16 bits

15 0
1. SP : Stack Pointer
BP= 16 bits

15 0
2. BP : Base Pointer
SI= 16 bits

15 0
3. SI : Source Index
DI= 16 bits
15 0
4. DI : Destination Index
Segment Registers
CS = 16 bits

15 0
1. CS : Code Segment
DS= 16 bits

15 0
2. DS : Data Segment
ES= 16 bits

15 0
3. ES : Extra Segment
SS= 16 bits

15 0
4. SS: Stack Segment
Instruction Pointer
IP = 16 bits

15 0
IP : Instruction Pointer

Accumulator Register
Base Register
Counter Register
Data Register
Code Segment
Instruction Pointer
Stack Segment
Stack Pointer
Base Pointer
Source Index
Destination Index
Data Segment
Extra Segment
MOV Instruction
• Copies the second operand (source) to the first operand (destination).
• The source operand can be an immediate value, general purpose register or
memory location.
• The destination register can be a general purpose register, or memory location.
• Both operands must be the same size, which can be a byte or a word.
Syntax:

MOV Destination, Source


Destination :-
1. Register
2. Memory location
Source :-
1. Register
2. Memory location
3. Immediate Value
EXAMPLE :-
MOV Register, Register
MOV Register, Memory Location
MOV Register, Immediate Value
MOV Memory Location, Register
MOV Memory Location, Memory Location
MOV Memory Location, Immediate Value
Register : AX, BX, CX, DX, AH, AL, BH, BL, CH, CL, DH, DL, DI, SI, BP, SP.
Memory Location : [3000H], [BX], [SI], etc….
Immediate Value : 5, -24, 3FH, 10001101b, etc….
EXAMPLE 1
Here is a short program that demonstrates the use
of MOV instruction:

MOV AX, 800H


MOV DS, AX

MOV BX, 15EH


MOV CX, BX
Homework
1. Write a program to store number 5H in
AL register, then transfer AL to BL
register.

2. Write a program to store number 4F1H


in AX register, then transfer the
number that stored in AX to BX
register.
Third Stage

Microprocessor Architecture
Lab.
Lecture 2
Lecture objective

The student will recognize the following objective:

1. ADD Instruction.
2. Subtract (SUB) Instruction.
ADD Instruction
ADD the content of source to the destination and store the result in the destination.
Syntax:
ADD Destination, Source
Destination :-
1. Register
2. Memory location
Source :-
1. Register
2. Memory location
3. Immediate Value
Note :- It is very important to check the size of the destination and source :-
ADD DX, BL invalid because DX is 16 bits (Word) and BL is 8 bits (Bytes).
ADD BL, CX invalid because BL is 8 bits (Byte) and CX is 16 bits (Word).
ADD CL, DL valid because both CL and DL are 8 bits (Byte).
ADD CX, AX valid because both CX and AX are 16 bits (Word).
EXAMPLE 1
Write a program to find the summation of :-
1. CL and BL Register (CL=2H, BL= 5H).
2. AL and DL Register (AL=5H, DL= 1H).
3. DH Register and number 5 (DH= 3H).
The Programming :
MOV CL, 2H
MOV BL, 5H
ADD CL, BL
MOV AL, 5H
MOV DL, 1H
ADD AL, DL
MOV DH, 3H
ADD DH, 5H
SUB Instruction
Subtract (SUB) the content of source to the destination and store the result in the destination.
Syntax:
SUB Destination, Source
Destination :-
1. Register
2. Memory location
Source :-
1. Register
2. Memory location
3. Immediate Value
Note :- It is very important to check the size of the destination and source :-
SUB DX, BL invalid because DX is 16 bits (Word) and BL is 8 bits (Bytes).
SUB BL, CX invalid because BL is 8 bits (Byte) and CX is 16 bits (Word).
SUB CL, DL valid because both CL and DL are 8 bits (Byte).
SUB CX, AX valid because both CX and AX are 16 bits (Word).
EXAMPLE 1
Write a program to find the subtraction of :-
1. CL from BH Register (CL=2H, BH= 5H).
2. AL from BL Register (AL=3H, BL= 7H).
3. Number 5 from DL register (DL= 9H).
The Programming :
MOV CL, 2H
MOV BH, 5H
SUB BH, CL
MOV AL, 3H
MOV BL, 7H
SUB BL, AL
MOV DL, 9H
SUB DL, 5H
EXAMPLE 2
Write a program to find the Solution for the following equation:-
𝐂𝐇 = (𝐀𝐋 + 𝐁𝐇) – (𝐁𝐋 + 𝐂𝐋)
Where 𝐀𝐋 = 𝟏𝟎𝐇
𝐁𝐇 = 𝟒𝐇
𝐁𝐋 = 𝟏𝐇
𝐂𝐋 = 𝟑𝐇
The Programming :
MOV AL,10H
MOV BH,4H
MOV BL,1H
MOV CL,3H
ADD AL,BH
ADD BL,CL
SUB AL,BL
MOV CH,AL
Homework
1. Write a program to find :-
𝐀𝐋 = 𝐁𝐋 − 𝐂𝐋 + 𝟓
Where 𝐁𝐋 = 𝟕𝐇
𝐂𝐋 = 𝟑𝐇

2. Write a program to Find the Solution for the


following equation:-
𝐂𝐇 = [(𝐀𝐋 – 𝐁𝐇) + (𝐁𝐋 – 𝐂𝐋)] + 𝟏𝟎
Where 𝐀𝐋 = 𝟏𝟎𝐇
𝐁𝐇 = 𝟒𝐇
𝐁𝐋 = 𝟏𝐇
𝐂𝐋 = 𝟑𝐇
Third Stage

Microprocessor Architecture
Lab.
Lecture 3
Lecture objective

The student will recognize the following objective :

1. Multiplication (MUL) Instruction.


MUL Instruction
This instruction is used to multiply the content of any register or memory
location with the content of accumulator register.
Syntax:
MUL Operand
Operand :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
When Operand is a byte (8 bits) :-

(AH, AL) = AL * Operand

When Operand is a word (16 bits) :-

(DX, AX) = AX * Operand


EXAMPLE 1
Write a program to Multiplication the content of
the registers BL and CL and store the result in DL
register.
Where BL = 5H, CL = 6H

The Programming :

MOV BL, 5H
MOV CL, 6H
MOV AL, BL
MUL CL
MOV DL, AL
EXAMPLE 2
Write a program to Multiplication the content of
the memory location 3000H (which equal to 5H)
with the content of register BL (BL = 10H) and
store the result in DL register.
The Programming :

MOV [3000H], 5H
MOV BL, 10H
MOV AL, [3000H]
MUL BL
MOV DL, AL
EXAMPLE 3
Write a program to find the Multiplication the
content of register BX = 267H with the content of
register CX = 501H and store the result in
memory location 2500H and 2510H.
The Programming :
MOV BX, 267H
MOV CX, 501H
MOV AX, BX
MUL CX
MOV [2500H], AX
MOV [2510H], DX
Homework
1. Write a program to find Multiplication the
content of to memory location [3000H] = 15H,
[2500H] = 20H and store the result in memory
location 2555H.
2. Find the Solution for the following equation :-
𝐂𝐇 = [(𝐀𝐋 ∗ 𝐁𝐇) + (𝐁𝐋 ∗ 𝐂𝐋)] + 𝟐𝟓
Where AL=4H
BH=5H
BL=1H
CL=3H
Third Stage

Microprocessor Architecture
Lab.
Lecture 4
Lecture objective

The student will recognize the following objective

1. Division (DIV) Instruction


DIV Instruction
This instruction is used to divide the content of accumulator register by any register or
memory location.
Syntax:
DIV Operand
Operand :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location
AH AL
When operand is a byte (8 bits) :-
The rest of the division Quotient
(AH, AL) = AX / Operand 8 Bit 8 Bit
DX AX
When operand is a word (16 bits) :- The rest of the division Quotient
DH DL AH AL
(DX, AX) = AX / Operand
16 Bit 16 Bit
EXAMPLE 1
Write a program to Divide the content of the registers BL
and CL and store the result in DX register?

Where BL = 25H, CL = 1H

Solution :-

MOV BL, 25H


MOV CL, 1H
MOV AL, BL
DIV CL
MOV DL, AL
MOV DH, AH
EXAMPLE 2
Write a program to Divide the content of the register CL
(which equal to 55H) by the content of register BL (BL =
55H) and store the result in CX register?

Solution :-

MOV CL, 55H


MOV BL, 55H
MOV AL, CL
DIV BL
MOV CL, AL
MOV CH, AH
EXAMPLE 3
Write a program to Divide the content of register BX =
267H by the content of register CX = 50H and store
the result in memory location 2500H and 2510H?

Solution :-
MOV BX, 267H
MOV CX, 50H
MOV AX, BX
DIV CX
MOV [2500H], AX
MOV [2510H], DX
Homework
1. Find the Solution for the following equation:-
CH=((AL * BH) + (BL / CL)) + 25
Where AL=4H
BH=5H
BL=10H
CL=3H
Third Stage

Microprocessor Architecture
Lab.
Lecture 5
Lecture objectives

The student will recognize the following objectives :

 Logical Instructions
1. “AND” Instruction.
2. “OR” Instruction.
AND Instruction
Logical AND between all bits of two operands. Result is stored in operand1.
(Logical Multiplication)
These rules apply :
1 AND 1 = 1
1 AND 0 = 0
0 AND 1 = 0
0 AND 0 = 0
Syntax:
AND Operand1, Operand2
Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, ................. ,etc.).
2. Memory location.
Operand2 :-
3. Register (AX, BX,CX,DX,AL,AH,BL,BH, ................. ,etc.).
4. Memory location.
5. Immediate Values.
EXAMPLE 1
Write a program to find the result of logical
operation “AND” between AL and BL and store the result
in CL register.

Where AL = 5H, BL = 6H

Solution :-
MOV AL, 5H 5H 0101
AND
MOV BL, 6H 6H 0110
---------
AND AL, BL
MOV CL, AL 0100 4H
EXAMPLE 2
Write a program to find the result of the logical
operation “AND” between (BX=6F29H) and (CX=34B6H)
and store the result in DX register.

Solution :-

MOV BX, 6F29H


MOV CX, 34B6H
AND BX, CX
MOV DX, BX
OR Instruction
Logical OR between all bits of two operands. Result is stored in operand1.
(Logical Summation)
These rules apply :
1 OR 1 = 1
1 OR 0 = 1
0 OR 1 = 1
0 OR 0 = 0
Syntax:
OR Operand1, Operand2
Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, ................. ,etc.).
2. Memory location.
Operand2 :-
3. Register (AX, BX,CX,DX,AL,AH,BL,BH, ................. ,etc.).
4. Memory location.
5. Immediate Values.
EXAMPLE 1
Write a program to find the result of the logical
operation “OR” between AL and BL and store the result in
CL register.

Where AL = 5H, BL = 6H

Solution :-
5H 0101
MOV AL, 5H OR
6H 0110
MOV BL, 6H ---------
OR AL, BL
0111 7H
MOV CL, AL
EXAMPLE 2
Write a program to find the r e s u l t of the logical
operation “OR” between (BX=6F29H) and (CX=34B6H)
and store the result in DX register.

Solution :-

MOV BX, 6F29H


MOV CX, 34B6H
OR BX, CX
MOV DX, BX
Homework
1. Write a program to perform “AND”
between (AX=6FEAH) and (BX=04BAH) and
store the result in CX register.

2. Write a program to perform “OR”


between (AX=60F4H) and (BX=5491H) and
store the result in DX register.
Third Stage

Microprocessor Architecture
Lab.
Lecture 6
Lecture objectives

The student will recognize the following objectives :

 Logical Instructions :
1. “XOR” Instruction.
2. “NOT” Instruction.
XOR Instruction
Logical XOR between all bits of two operands. Result is stored in operand.1
These rules apply:
0XOR 0 =0
0XOR 1 =1
1XOR 1 =0
1XOR 0 =1
Syntax:
XOR Operand2dnarepO ,1
Operand-: 1
1. Register (AX, BX,CX,DX,AL,AH,BL,BH,.(.cte,.………………
2. Memory location.
Operand-: 2
3. Register (AX, BX,CX,DX,AL,AH,BL,BH,.(.cte,.………………
4. Memory location.
5. Immediate Values.
EXAMPLE 1
Write a program to perform the operation “XOR”
between AL and BL and store the result in CL register.

Where AL = 5H, BL = 6H

Solution :-

MOV AL, 5H 5H 0101


XOR
MOV BL, 6H 6H 0110
XOR AL, BL ---------
MOV CL, AL 0011 3H
EXAMPLE 2
Write a program to perform the operation “XOR”
between (BX=6F29H) and (CX=34B6H) and store the
result in DX register.

Solution :-

MOV BX, 6F29H


MOV CX, 34B6H
XOR BX, CX
MOV DX, BX
NOT Instruction
Invert each bit of the operand.
These rules apply :
NOT 1 = 0
NOT 0 = 1
Syntax:
NOT Operand1
Operand1:-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.).
2. Memory location.
EXAMPLE 1
Write a program to perform the operation “NOT”
for AL and BL.
Where AL = 75H, BL = 65H

Solution :-
NOT
MOV AL, 75H 75H 0111 0101 1000 1010 8AH
NOT AL
MOV BL, 65H
NOT BL 65H 0110 0101
NOT
1001 1010 9AH
EXAMPLE 2
Write a program to perform the operation “NOT”
on (BX=6F29H) and (CX=34B6H).

Solution :-

MOV BX, 6F29H


NOT BX
MOV CX, 34B6H
NOT CX
Homework
1. Write a program to perform this logic gate circuit
in assembly language

Where AL=5h, BL=10H, [2500h]=19H, and CL=99H


Third Stage

Microprocessor Architecture
Lab.
Lecture 7
Lecture objective

The student will recognize the following Contents :

1. “INC” (Increment) Instruction.


2. “DEC” (Decrement) Instruction.
INC Instruction
This instruction increases the contents of the specified Register or Memory
location by 1.

• Increment operand by one.


Operand = Operand + 1
Syntax:

INC Operand
Operand :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
EXAMPLE 1
Write a program to increases the content of the
specified Register (AL) by 1 and store the result in CL
register.

Where AL = 5H

Solution :-

MOV AL, 5H
INC AL 5H + 1 = 6H
MOV CL, AL
EXAMPLE 2
Write a program to increases the content of the
specified Register (BX) by 1 and store the result in DX
register.

Where BX = 555H

Solution :-

MOV BX, 555H


INC BX 555H + 1 = 556H
MOV DX, BX
DEC Instruction
The decrement instruction subtracts 1 from the contents of the specified
Register or Memory location.
• Decrement operand by one.
Operand = Operand - 1

Syntax:

DEC Operand
Operand :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
EXAMPLE 1
Write a program to Subtracts the content of the
specified Register (AL) by 1 and store the resul t in CL
register.

Where AL = 5H

Solution :-

MOV AL, 5H
DEC AL 5H – 1 = 4H
MOV CL, AL
EXAMPLE 2
Write a program to Subtracts the contents of the
specified Register (BX) by 1 and store the result in DX
register.

Where BX = 555H

Solution :-

MOV BX, 555H


DEC BX 555H – 1 = 554H
MOV DX, BX
Homework
1. Write a program in assembly language to
perform the following equation:
AX + 1 = BL + BH – CL
Where BX=1850H, CL=0

2. By using “DEC” Instruction, write a program to


find the result for following equation :
AL = BL – 1
Where BL = 10H
Third Stage

Microprocessor Architecture
Lab.
Lecture 8
Lecture objective

The student will recognize the following Contents:

1. Shift Arithmetic Left “SAL ”Instruction.


2. Shift Logic Left “SHL ”Instruction.
3. Shift Arithmetic Right “SAR ”Instruction.
4. Shift Logic Right “SHR ”Instruction.
SAL / SHL Instruction
This instruction shifts the bits in the operand specified by Operand1 to its
left by the count specified in Operand2. As a bit is shifted out of LSB
position a 0 is kept in LSB position. CF will contain MSB bit.

Syntax: Register

SAL Operand1, Operand2 CF bit MSB LSB 0


SHL Operand1, Operand2
Most Significant Least Significant
Operand1 :- bit bit
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, ..................,etc.)
2. Memory location.
Operand2 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
3. Immediate Values.
EXAMPLE 1
Write a program to perform this equation :
AL = BL + CL
Where BL = 04H, CL = 05H
After that, Shift Register AL to the left by one bit.

Solution :-

MOV BL, 04H BL 04H ADD


MOV CL, 05H CL 05H
ADD BL, CL ---------
MOV AL, BL 09H 0000 1001
SAL AL, 1 CF 0 0001 0010
12H
EXAMPLE 2
Write a program to perform this Logic gate:
BL
AL
Where BL = 04H, CL = 05H CL
After that, Shift Register AL to the left by two bits.
Solution :-
MOV BL, 04H BL 0000 0100 AND
MOV CL, 05H CL 0000 0101
AND BL, CL -------------------
MOV AL, BL 0000 0100
SHL AL, 2 CF 0 0000 1000 08H
CF 0 0001 0000 10H
SAR / SHR Instruction
This instruction shifts each bit in the specified destination to the right and 0 is
stored at MSB position. The LSB is shifted into the carry flag. The destination
can be a byte or a word. It can be a register or in a memory location. The
number of shifts is indicated by count.
Register
Syntax:
SAR Operand1, Operand2 0 MSB LSB bit CF
SHR Operand1, Operand2
Most Significant Least Significant
Operand1 :-
bit bit
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
Operand2 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
3. Immediate Values.
EXAMPLE 1
Write a program to perform this equation :
AL = BL + CL
Where BL = 04H, CL = 05H
After that, Shift Register AL to the Right by one bit.

Solution :-

MOV BL, 04H BL 04H ADD


MOV CL, 05H CL 05H
ADD BL, CL ---------
MOV AL, BL 09H 0000 1001
SAR AL, 1 0000 0100 1 CF
04H
EXAMPLE 2
Write a program to perform this Logic gate:
BL
AL
Where BL = 04H, CL = 05H CL
After that, Shift Register AL to the Right by two bits.
Solution :-
MOV BL, 04H BL 0000 0100 AND
MOV CL, 05H CL 0000 0101
AND BL, CL -------------------
MOV AL, BL 0000 0100
SHR AL, 2 02H 0000 0010 0 CF
01H 0000 0001 0 CF
Homework
1. Write a program to perform this equation :
AL = BL + CL – DL
Where BL = 10H, CL = 50H, DL = 20H
After that, Shift Register AL to the left by Three bits.
2. Write a program to perform this Logic
gate: BL
CL
AL
DL

Where BL = 30H, CL = 11H, DL = 22H


After that, Shift Register AL to the left by Two bits.
Third Stage

Microprocessor Architecture
Lab.
Lecture 9
Lecture objective

The student will recognize the following Contents :

 Rotate Left “ROL” Instruction.


ROL Instruction
This instruction shift all bits left, the bit that goes off is set to CF and the
same bit is inserted in the right most position.
• ROL (rotate) shifts each bit to the left.
• The highest bit is copied into both the Carry flag and into the lowest bit.
Syntax:

ROL Operand1, count


Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH,.................. ,etc.)
2. Memory location.
count :-
1. Immediate Values.
ROL Instruction

AL = 56H AL = 0101 0110 b

0 1 0 1 0 1 1 0

0 1 0 1 0 1 1 0 0

CF ROL
EXAMPLE 1
Write a program to Perform this equation :
AL = BL + CL
Where BL = 50H, CL = 06H
After that, Rotate Left Register AL by one bit.

Solution :-

MOV BL, 50H BL 50H ADD


MOV CL, 06H CL 06H
ADD BL, CL ---------
MOV AL, BL 56H 0101 0110
ROL AL, 1 CF 0 1010 1100
ACH
ROL Instruction

AL = 56H AL = 0101 0110 b


CF
0 1 0 1 0 1 1 0

0 1 0 1 0 1 1 0 0 ROL 1

1 0 1 0 1 1 0 0 1 ROL 2
CF
EXAMPLE 2
Write a program to Perform this equation :
AL = BL – CL + 5
Where BL = 60H, CL = 04H
After that, Rotate left register AL by two bit.
Solution :- BL 60H SUB
MOV BL, 60H CL 04H
ADD
MOV CL, 04H 05H
SUB BL, CL ---------
ADD BL, 5H 61H 0110 0001
MOV AL, BL ROL 1 CF 0 1100 0010 C2H
ROL AL, 2 ROL 2 CF 1 1000 0101 85H
Homework
1. Write a program to perform this equation :
AL = BL + CL – DL
Where BL = 70H, CL = 20H, DL = 20H
After that, Rotate Left Register AL by Three bits.

2. Write a program to perform this logic gate:


BL
CL
AL + 10
DL

Where BL = 40H, CL = 10H, DL = 22H


After that, Rotate Left Register AL by Two bits.
Third Stage

Microprocessor Architecture
Lab.
Lecture 10
Lecture objective

The student will recognize the following Instructions :

 Rotate Carry Left “RCL” Instruction.


 Clear Carry Flag “CLC”.
 Set Carry “STC”.
RCL Instruction
This instruction shift all bits left, the bit that goes off is set to CF and previous
value of CF is inserted to the right-most position.
• RCL (rotate carry left) shifts each bit to the left.
• Copies the Carry flag to the least significant bit.
• Copies the most significant bit to the Carry flag.
Syntax:
RCL Operand1, count
Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
count :-
1. Immediate Values.
RCL Instruction

AL = 41H AL = 0100 0001 b


0 1 0 0 0 0 0 1

CLC Clear Carry Flag CF=0


CF
0 1 0 0 0 0 0 1 0 RCL 1
EXAMPLE 1
Write a program to perform this equation :
AL = BL + CL
Where BL = 40H, CL = 06H, CF = 0
After that, Rotate Carry Left Register AL to one bit.
Solution :-
MOV BL, 40H BL 40H ADD
MOV CL, 06H CL 06H
ADD BL, CL ---------
MOV AL, BL 46H 0100 0110
CLC CF = 0 CF 0 1000 1100
8CH
RCL AL, 1
RCL Instruction

AL = 41H AL = 0100 0001 b


0 1 0 0 0 0 0 1
CF
STC Set Carry CF=1
0 1 0 0 0 0 0 1 1 RCL 1

1 0 0 0 0 0 1 1 0 RCL 2
EXAMPLE 2
Write a program to perform this equation :
AL = BL – CL + 5
Where BL = 40H, CL = 04H, CF = 1
After that, Rotate Carry Left Register AL by Two bit.
Solution :-
MOV BL, 40H BL 40H SUB
MOV CL, 04H CL 04H
ADD
SUB BL, CL 05H
ADD BL, 5H ---------
MOV AL, BL 41H 0100 0001
RCL 1 CF 0 1000 0011 83H
STC
RCL AL, 2 RCL 2 CF 1 0000 0110 06H
Homework
1. Write a program to perform this equation :
AL = BL + CL – DL + 20H
Where BL = 66H, CL = 25H, DL = 40H, CF = 0
After that, Rotate Carry Left Register AL by Four bits.
2. Write a program to perform this Logic
gate:
BL
CL AL + BL
DL

Where BL = 05H, CL = 77H, DL = 80H, CF = 1


After that, Rotate Carry Left Register AL by Two bits.
Third Stage

Microprocessor Architecture
Lab.
Lecture 11
Lecture objective

The student will recognize the following Instruction:

 Rotate Right “ROR ”Instruction.


ROR Instruction
This instruction shift all bits right, the bit that goes off is set to CF and the
same bit is inserted to the left-most position.
• ROR (rotate right) shifts each bit to the right.
• The lowest bit is copied into both the Carry flag and into the highest bit.
Syntax:

ROR Operand1, count


Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH,.................. ,etc.)
2. Memory location.
count :-
1. Immediate Values.
ROR Instruction

AL = 56H AL = 0101 0110 b

0 1 0 1 0 1 1 0

0 0 1 0 1 0 1 1 0

ROR CF
EXAMPLE 1
Write a program to perform this equation :
AL = BL + CL
Where BL = 50H, CL = 06H
After that, Rotate Right Register AL by one bit.

Solution :-

MOV BL, 50H BL 50H ADD


MOV CL, 06H CL 06H
ADD BL, CL ---------
MOV AL, BL 56H 0101 0110
ROR AL, 1 0010 1011 0 CF
2BH
ROR Instruction

AL = 56H AL = 0101 0110 b


CF
0 1 0 1 0 1 1 0

ROR 1 0 0 1 0 1 0 1 1 0

ROR 2 1 0 0 1 0 1 0 1 1

CF
EXAMPLE 2
Write a program to perform this equation :
AL = BL – CL + 5
Where BL = 60H, CL = 04H
After that, Rotate Right Register AL by Two bit.
Solution :- BL 60H SUB
MOV BL, 60H CL 04H
ADD
MOV CL, 04H 05H
SUB BL, CL ---------
ADD BL, 5H 61H 0110 0001
MOV AL, BL ROR 1 B0H 1011 0000 1 CF
ROR AL, 2 ROR 2 58H 0101 1000 0 CF
Homework
1. Write a program to perform this equation :
AL = BL – CL + DL *2H
Where BL = 40H, CL = 20H, DL = 10H
After that, Rotate Right Register AL by Two bits.
2. Write a program to perform this Logic
gate:
BL
AL
CL
Where BL = 77H, CL = 33H.
After that, Rotate Right Register AL by four bits.
Third Stage

Microprocessor Architecture
Lab.
Lecture 12
Lecture objective

The student will recognize the following Instruction :

 Rotate Carry Right “RCR”


Instruction.
RCR Instruction
This instruction shift all bits right, the bit that goes off is set to CF and
previous value of CF is inserted to the leftmost position.
• 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.
Syntax:

RCR Operand1, count


Operand1 :-
1. Register (AX, BX,CX,DX,AL,AH,BL,BH, .................. ,etc.)
2. Memory location.
count :-
1. Immediate Values.
RCR Instruction

AL = 41H AL = 0100 0001 b


0 1 0 0 0 0 0 1

STC Set Carry CF=1


CF

RCR 1 1 0 1 0 0 0 0 0 1
EXAMPLE 1
Write a program to perform this equation :
AL = BL + CL
Where BL = 40H, CL = 06H, CF = 1
After that, Rotate Carry Right Register AL by one bit.
Solution :-
MOV BL, 40H BL 40H ADD
MOV CL, 06H CL 06H
ADD BL, CL ---------
MOV AL, BL 46H 0100 0110
STC CF = 1 1010 0011 0 CF
A3H
RCR AL, 1
RCR Instruction

AL = 41H AL = 0100 0001 b


0 1 0 0 0 0 0 1
CLC Clear Carry Flag CF=0 CF

RCR 1 0 0 1 0 0 0 0 0 1

RCR 2 1 0 0 1 0 0 0 0 0
EXAMPLE 2
Write a program to perform this equation :
AL = BL – CL + 5
Where BL = 40H, CL = 04H, CF = 0
After that, Rotate Carry Right Register AL by Two bit.
Solution :-
MOV BL, 40H BL 40H SUB
MOV CL, 04H CL 04H
ADD
SUB BL, CL 05H
ADD BL, 5H ---------
MOV AL, BL 41H 0100 0001
20H 0010 0000 1 CF
CLC RCR 1

RCR AL, 2 RCR 2 90H 1001 0000 0 CF


Homework
1. Write a program to perform this equation :
AL = BL – CL + DL *3
Where BL = 40H, CL = 20H, DL = 10H, CF = 0
After that, Rotate Carry Right Register AL by Three bits.
2. Write a program to perform this Logic gate:
BL
CL
AL
DL
CH

Where BL = 70H, CL = 30H, DL = 42H, CH = 50H CF = 1


After that, Rotate Carry Right Register AL by four bits.

You might also like