View
226
Download
0
Category
Preview:
Citation preview
8/14/2019 Instruction Set pec lecture
1/52
INTRODUCTION TO 8085 INSTRUCTION SET
8/14/2019 Instruction Set pec lecture
2/52
INTRODUCTION
A microcomputer performs a task by reading and executing the
set of instructions written in its memory.
This set of instructions, written in a sequence, is called a
program.
Each instruction in the program is a command, in binary, to the
microprocessor to perform an operation.
8/14/2019 Instruction Set pec lecture
3/52
DATA TRANSFER OPERATIONS
The data transfer instructions copy data from a sourceinto a destination without modifying the contents of thesource.
The previous contents of the destination are replaced bythe contents of the source.
8/14/2019 Instruction Set pec lecture
4/52
DATA TRANSFER OPERATIONS
8/14/2019 Instruction Set pec lecture
5/52
MACHINE CONTROL OPERATIONS
8/14/2019 Instruction Set pec lecture
6/52
EXAMPLE 1
Load the accumulator A with the data byte 82H (the letterH indicates hexadecimal number), and save the data inregister B.
8/14/2019 Instruction Set pec lecture
7/52
Instructions: MVI A, 82H,
MOV B,A
The first instruction is a 2-byte instruction that loads the
accumulator with the data byte 82H, and the secondinstruction MOV B,A copies the contents of the
accumulator in register B without changing the contents
of the accumulator.
8/14/2019 Instruction Set pec lecture
8/52
EXAMPLES
Get a data to accumulator and then move it to register B.
Load the content of memory location 200H directly to the
accumulator, then transfer it to the register B.
8/14/2019 Instruction Set pec lecture
9/52
Get a data to accumulator and then move it to register B. MVI A,05(data)
MOV B,A
8/14/2019 Instruction Set pec lecture
10/52
Load the content of memory location 200H directly to the
accumulator, then transfer it to the register B. LDA 2000H
MOV B,A
8/14/2019 Instruction Set pec lecture
11/52
ARITHMETIC AND LOGIC INSTRUCTIONSARITHMETIC AND LOGIC INSTRUCTIONS
8/14/2019 Instruction Set pec lecture
12/52
ARITHMETIC OPERATIONSARITHMETIC OPERATIONS
Addition,
Subtraction,
Increment,
Decrement.
8/14/2019 Instruction Set pec lecture
13/52
ARITHMETIC OPERATIONSARITHMETIC OPERATIONS
8/14/2019 Instruction Set pec lecture
14/52
ARITHMETIC OPERATIONSARITHMETIC OPERATIONS
8/14/2019 Instruction Set pec lecture
15/52
ARITHMETIC OPERATIONSARITHMETIC OPERATIONS
8/14/2019 Instruction Set pec lecture
16/52
ADDITIONADDITION
Addition takes several forms in the 8085
microprocessor like 8-bit binary, 16-bit binary etc
8/14/2019 Instruction Set pec lecture
17/52
ADDITIONADDITION
8/14/2019 Instruction Set pec lecture
18/52
The contents of the accumulator are 93H andcontents of a register C is B7 H. Add both thecontents.
8/14/2019 Instruction Set pec lecture
19/52
ADDITIONADDITION
8/14/2019 Instruction Set pec lecture
20/52
Add the number 35H to directly to the sum in theprevious example when the CY flag is set.
8/14/2019 Instruction Set pec lecture
21/52
ADDITIONADDITION
8/14/2019 Instruction Set pec lecture
22/52
Write a program to perform the following functions, Load the number 8BH in register D.
Load the number 6FH in register C.
Increment the contents of register C by one.
Add the contents of register C and D and display the sum at theoutput PORT1.
8/14/2019 Instruction Set pec lecture
23/52
MVI D,8DH
MVI C,6FH
INR C
MOV A,CADD D
OUT PORT1
HLT
8/14/2019 Instruction Set pec lecture
24/52
SubtractionSubtraction
The 8085 supports 8-bit binary subtraction and decrement.The 8085 supports 8-bit binary subtraction and decrement. It also supports a subtraction instruction that allows a borrow to beIt also supports a subtraction instruction that allows a borrow to be
propagated through additional bytes of a number.propagated through additional bytes of a number.
The subtract-with-borrow instruction aids in the subtraction ofThe subtract-with-borrow instruction aids in the subtraction of
multiple-byte numbers. .multiple-byte numbers. .
8/14/2019 Instruction Set pec lecture
25/52
SubtractionSubtraction
The 8085 performs subtraction by using the method
of 2s complement.Subtraction can be performed by using either: the instruction SUB to subtract contents of a source register or
the instruction SUI to subtract an 8-bit number from contents
of the accumulator. In either case, the accumulator contents are regarded as
minuend (the number from which to subtract).
8/14/2019 Instruction Set pec lecture
26/52
SubtractionSubtraction
8/14/2019 Instruction Set pec lecture
27/52
SubtractionSubtraction
The 8085 performs the following steps internally to executeThe 8085 performs the following steps internally to execute
the instruction SUB (or SUI):the instruction SUB (or SUI): Step1:Converts subtrahend (the number to be subtracted)Step1:Converts subtrahend (the number to be subtracted)
into its 1s complement.into its 1s complement.
Step2:Adds 1 to 1s complement to obtain 2s complementStep2:Adds 1 to 1s complement to obtain 2s complement
of the subtrahend.of the subtrahend.
Step3:Add 2s complement to the minuend (the contents ofStep3:Add 2s complement to the minuend (the contents of
the accumulator).the accumulator).
Step4:Step4:
Complements the Carry flagComplements the Carry flag
::
The programmer can check whether the resultThe programmer can check whether the result
indicates the true magnitude by checking the CY flag.indicates the true magnitude by checking the CY flag.
If CY flag is reset the result is positive and if CY flagIf CY flag is reset the result is positive and if CY flag
is set, the result is expressed in 2s complement.is set, the result is expressed in 2s complement.
8/14/2019 Instruction Set pec lecture
28/52
Illustrative Program: Subtraction of Two NumbersIllustrative Program: Subtraction of Two Numbers
PROBLEM STATEMENTPROBLEM STATEMENT Write a program to do the following:Write a program to do the following:
Load the number 30H in register B and 39H in register C.Load the number 30H in register B and 39H in register C.
Subtract 39H from 30H.Subtract 39H from 30H.
Display the answer at PORT I.Display the answer at PORT I.
8/14/2019 Instruction Set pec lecture
29/52
Illustrative Program: Subtraction of Two NumbersIllustrative Program: Subtraction of Two Numbers
8/14/2019 Instruction Set pec lecture
30/52
Illustrative Program: Subtraction of Two NumbersIllustrative Program: Subtraction of Two Numbers
PROGRAM DESCRIPTIONPROGRAM DESCRIPTION Registers B and C are loaded with 30H and 39H, respectively.Registers B and C are loaded with 30H and 39H, respectively.
The instruction MOV A,B copies 30H into the accumulatorThe instruction MOV A,B copies 30H into the accumulator
(shown as register contents).(shown as register contents).
8/14/2019 Instruction Set pec lecture
31/52
Illustrative Program: Subtraction of Two NumbersIllustrative Program: Subtraction of Two Numbers
To execute the instruction SUB C the microprocessorTo execute the instruction SUB C the microprocessor
performs the following steps internally:performs the following steps internally:
8/14/2019 Instruction Set pec lecture
32/52
Illustrative Program: Subtraction of Two NumbersIllustrative Program: Subtraction of Two Numbers
PROGRAM DESCRIPTIONPROGRAM DESCRIPTION The number F7H is a 2s complement of the magnitude (39H-The number F7H is a 2s complement of the magnitude (39H-
30H)=09H.30H)=09H.
This Cy flag is set, indicating the answer is in 2s complement.This Cy flag is set, indicating the answer is in 2s complement.
The instruction OUT displays F7 at PORT1.The instruction OUT displays F7 at PORT1.
8/14/2019 Instruction Set pec lecture
33/52
NOTNOT
The CMA instruction (2FH in machine language), ones-The CMA instruction (2FH in machine language), ones-
complements the contents of the accumulator.complements the contents of the accumulator.
This operation, which affects none of the flag bits, causesThis operation, which affects none of the flag bits, causes
each bit of the accumulator to be inverted (changed fromeach bit of the accumulator to be inverted (changed from
1 to 0 or 0 to 1).1 to 0 or 0 to 1).
The CMA instruction causes the accumulator to appear asThe CMA instruction causes the accumulator to appear as
eight inverters (or NOT).eight inverters (or NOT).
8/14/2019 Instruction Set pec lecture
34/52
LOGIC INSTRUCTIONSLOGIC INSTRUCTIONS
Four basic logic functions:Four basic logic functions: NOTNOT
ANDAND
OR andOR and
Exclusive-OR.Exclusive-OR.
8/14/2019 Instruction Set pec lecture
35/52
The AND OperationThe AND Operation
8/14/2019 Instruction Set pec lecture
36/52
The AND OperationThe AND Operation
8/14/2019 Instruction Set pec lecture
37/52
The OR OperationThe OR Operation
Has two separate functions in a microprocessor-basedHas two separate functions in a microprocessor-based
system:system: It selectively sets bits of the accumulator orIt selectively sets bits of the accumulator or
Replaces discrete OR gates.Replaces discrete OR gates.
The inclusive-OR instruction functions as eightThe inclusive-OR instruction functions as eight
independent two-input OR gates.independent two-input OR gates.
This instruction replaces two 7432 two-input OR gates.This instruction replaces two 7432 two-input OR gates.
8/14/2019 Instruction Set pec lecture
38/52
The OR OperationThe OR Operation
8/14/2019 Instruction Set pec lecture
39/52
The OR OperationThe OR Operation
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
8/14/2019 Instruction Set pec lecture
40/52
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
PortsPorts
PROBLEM STATEMENTPROBLEM STATEMENT Two input port with eight switches (each port) at addressTwo input port with eight switches (each port) at address
00H and OIH (Figure 6.9) is connected to the00H and OIH (Figure 6.9) is connected to the
microcomputer to control the same appliances and lightsmicrocomputer to control the same appliances and lights
from the bedroom as well as from the kitchen.from the bedroom as well as from the kitchen.
Write instructions to turn on the devices from any of theWrite instructions to turn on the devices from any of the
input ports.input ports.
ll f
8/14/2019 Instruction Set pec lecture
41/52
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
PortsPorts
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
8/14/2019 Instruction Set pec lecture
42/52
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
PortsPorts
PROBLEM ANALYSISPROBLEM ANALYSIS To turn on the appliances from any one of the input ports, theTo turn on the appliances from any one of the input ports, the
microprocessor needs to read the switches at both ports and logicallymicroprocessor needs to read the switches at both ports and logically
OR the switch positions.OR the switch positions.
Assume that the switch positions in one input port (located in theAssume that the switch positions in one input port (located in thebedroom) correspond to the data byte 9lH and the switch positionsbedroom) correspond to the data byte 9lH and the switch positions
in the second port (located in the kitchen) correspond to the datain the second port (located in the kitchen) correspond to the data
byte A8H.byte A8H.
The person in the bedroom wants to turn on the air conditioner, theThe person in the bedroom wants to turn on the air conditioner, the
radio, and the bedroom light; and the person in the kitchen wants toradio, and the bedroom light; and the person in the kitchen wants toturn on the air-conditioner, the coffeepot, and the kitchen light.turn on the air-conditioner, the coffeepot, and the kitchen light.
By ORing these two data bytes, the MPU can turn ON the necessaryBy ORing these two data bytes, the MPU can turn ON the necessary
appliances.appliances.
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
8/14/2019 Instruction Set pec lecture
43/52
Illustrative Program: ORing Data from Two InputIllustrative Program: ORing Data from Two Input
PortsPorts
8/14/2019 Instruction Set pec lecture
44/52
Exclusive OR (XOR)Exclusive OR (XOR)
8/14/2019 Instruction Set pec lecture
45/52
ROTATE INSTRUCTIONSROTATE INSTRUCTIONS
8/14/2019 Instruction Set pec lecture
46/52
SUMMARYSUMMARY
Most arithmetic and logic instructions affect the flag bits,whereas the data transfer instructions did not affect theflags.
Many arithmetic and logic instructions gate the result into
the accumulator.The arithmetic and logic instructions use register,
immediate, and register indirect addressing.
Addition is available as add 1 to any register or register pair,
8- and 16-bit binary, 8-bit binary with carry, and binary-coded decimal (BCD).
8/14/2019 Instruction Set pec lecture
47/52
SUMMARYSUMMARY
Subtraction is available as subtract 1 from any register orSubtraction is available as subtract 1 from any register orregister pair, 8-bit binary, 8-bit binary with borrow, and asregister pair, 8-bit binary, 8-bit binary with borrow, and as
a compare, which is a form of subtraction.a compare, which is a form of subtraction.
The logic operations are AND, OR, exclusive-OR, andThe logic operations are AND, OR, exclusive-OR, and
invert.invert.The logic instructions are ideal for control because ANDThe logic instructions are ideal for control because AND
clears bits, OR sets bits, and exclusive-OR complementsclears bits, OR sets bits, and exclusive-OR complements
bits. This gives the programmer complete control over eachbits. This gives the programmer complete control over each
bit of a number.bit of a number.Programmed logic replaces discrete logic circuits at aProgrammed logic replaces discrete logic circuits at a
substantial cost advantage.substantial cost advantage.
8/14/2019 Instruction Set pec lecture
48/52
SUMMARYSUMMARY
Some 8085 instructions have hidden functions: ADD Ashifts the accumulator left, and DAD H shifts HL left.
Both ANA A and ORA A test the accumulator, and SUB Aand XRA A clear the accumulator.
The rotate commands create the shift-right functions:logical and arithmetic shift right.
8/14/2019 Instruction Set pec lecture
49/52
SubtractionSubtraction
P= 0 Odd parity
8/14/2019 Instruction Set pec lecture
50/52
Subtract with BorrowSubtract with Borrow
8/14/2019 Instruction Set pec lecture
51/52
Subtract with BorrowSubtract with Borrow
8/14/2019 Instruction Set pec lecture
52/52
ExampleExampleSuppose that the number in the DE pair must be subtracted fromthe BC pair. The least significant is operated on first. Once the
difference of C and E is found, the D register is subtracted fromthe B register with a borrow. The subtraction with borroweffectively propagates the borrow through the most significantbyte of the result.
Recommended