8085 instructions and addressing modes

1,167 views 44 slides Jul 23, 2021
Slide 1
Slide 1 of 44
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44

About This Presentation

Detail Description of instrcutions and addressing modes of 8085


Slide Content

Addressing Modes
and Instruction Set of
8085
1
SSP/EC-403/2021

Addressing Modes
•Addressingmodeisthemannerinwhichanoperand
isgiveninaninstruction.
•Operand:Thevalueonwhichprogrammerwantto
operate.
•Variousformatsforspecifyingoperandsarecalled
addressingmodes.
•Typesofaddressingmode:
▫ImmediateAddressing
▫RegisterAddressing
▫MemoryDirectAddressing
▫IndirectAddressing
▫ImplicitorImpliedAddressing
2
SSP/EC-403/2021

Immediate Addressing
•Dataisgivenintheinstruction.
•Transferstheoperandgivenintheinstruction.
•Abyteorword–tothedestinationregisterormemory
location.
•Operandispartoftheinstruction.
•Operandisstoredintheregistermentionedinthe
instruction.
•Nomemoryreferencetofetchdata.
•Advantage:
▫Executesfaster
▫Simple
•Disadvantage:
▫Biginstruction(Size)
•Eg:ADI98H;MVIA25H.LXIH5000HEtc.
3
SSP/EC-403/2021

Immediate Addressing
SSP/EC-403/2021
4
Instruction
Opcode Operand
MVI A, 25
A
25H
25H

Register Addressing
•Thedataisgivenbyaregister.
•Transfersacopyofabyteorwordfromthesource
registertothedestinationregister.
•Operandisintheregisternamedintheinstruction.
•1byteinstruction.
•Theoperandiswithintheprocessor,sothe
executionisfaster.
•Advantage:
▫Faster
▫Smallsize
•Disavantage:
▫Verylimitedregisterspace.
▫Complex
•Eg:MOVA,B;ADDBetc,
5
SSP/EC-403/2021

Register Direct Addressing
SSP/EC-403/2021
6
Opcode Register Address
Registers, in CPU
Operand
Instruction
MOV A,B
B
A
65H
65H

Memory Direct Addressing
•Movesabyteorwordbetweenmemory
locationandregister.
•Thememoryaddressoftheoperandisgivenin
theinstruction.
•Doesnotsupportmemorytomemorytransfer.
•Advantage:
▫Simple
•Disadvantage:
▫Toolarge
▫Rigid
•Eg:STA9000H,LDA9500Hetc.
7
SSP/EC-403/2021

Memory Direct Addressing
SSP/EC-403/2021
8
Instruction
Opcode
Operand
Memory Address
Memory
STA 9000H
9000
A
45H
45H

Indirect Addressing
•Transfersabyteorwordbetweenaregisteranda
memorylocation.
•Addressofamemorylocationisstoredinaregister
whichisspecifiedintheinstruction.
•Theeffectiveaddressiscalculatedbytheprocessorusing
thecontentoftheregisterspecifiedintheinstruction.
•Usedtoaccessseriesoflocations.
•Advantage:
▫Flexible
▫Loops
•Disaadvantage:
▫Complex
•Eg:MOVA,M;LDAXRp;STAXRpetc.
9
SSP/EC-403/2021

Indirect Addressing
SSP/EC-403/2021
10
Opcode Register Address
Memory
Operand
Instruction
Memory address
to operand
Register

Implicit or Implied Addressing
•Wedon’tgivethedataoraddressintheinstruction.
•Instructionitselfspecifiesthedatatobeoperated
upon.
•Doesn’trequiredanyoperand.
•Usedonparticularoperand.
•Advantage:
▫Simple
▫Small
•Disadvantage:
▫Rigid
•Eg:CMA,XCHG,SPHL,XTHL etc.
CMA:
11
SSP/EC-403/2021
A01HFFH

Quick Overview
•Immediate:
▫Data in the instruction.
▫MVI B, 40H B 40H
▫LXIB, 4000H BC 4000H
•Register:
▫Data is in the register.
▫MOV A,B [A] [B]
▫INR B [B] [B+1]
▫INX B [BC] [BC+1]
•Direct:
▫Address is in the instruction.
▫LDA 8000H [A] [8000]
▫STA 9000H [A] [9000]
•Indirect:
▫Address is in the register.
▫LDAX B [A] [BC]
▫STAX B [A] [BC]
•Implied:
▫Implied
▫STC CY 1
▫CMC CY CY
SSP/EC-403/2021
12

Instruction Set
Aninstructionisabinarypatterndesignedinsideamicroprocessortoperform
aspecificfunction.
Theassemblylanguagemnemonicsarethecodesforthesebinarypatternsso
thattheusercaneasilyunderstandthefunctionperformedbythese
instructions.
Theentiregroupofinstructionsthatamicroprocessorsupportsiscalled
InstructionSet.
•BasedonthedesignoftheALUandthedecodingunit,themicroprocessor
manufacturersgenerallylistouttheinstructionsetfortheevery
microprocessormanufactured.
•Thepurposeofaninstructionsetistofacilitatethedevelopmentofefficient
programsbyusers.
•Theinstructionsetisbasedonthearchitectureoftheprocessor.
•Everyµphasitsowninstructionset.
•Instructionsetconsistofbothassemblylanguagemnemonicsand
correspondingmachinecode.
13
SSP/EC-403/2021

Instruction Set of 8085
•Intel8085processorhasitsownsetofinstructionslisted
bothinmnemonicsandmachinecode,alsocalledas
objectcode.
•As8085isan8-bitprocessor.
•Themachinecodesfortheinstructionsarealso8-bits
wide.
•Ithas246instructions.
Eachinstructionisrepresentedbyan8-bitbinaryvalue.
These8-bitsofbinaryvalueiscalledOp-Codeor
InstructionByte
SSP/EC-403/2021
14

Classification of Instruction Set
Instruction set
Based on functionality Based on length
DataTransferInstruction
ArithmeticInstructions
LogicalInstructions
BranchingInstructions
Stack/IOandMcControlInstructions
One –byte
instruction
Two-byte
instruction
Three-byte
instruction
15
SSP/EC-403/2021

Classification of Instruction Set
•Basedonlength
▫One-ByteInstructions
▫Two-ByteInstructions
▫Three-ByteInstructions
16
SSP/EC-403/2021

One-Byte Instructions
•Instructionsrequireonlyonebyteinmachine
language.
•Theseinstructionsjusthavethemachinecodeor
op-codetorepresenttheoperationtobe
performed.
•Eg:MOVA,B;ADDM;XRAAetc.
▫MOVA,B Opcode Onebyte
17
SSP/EC-403/2021

Two-Byte Instructions
•Instructionsthatrequiretwobytesinmachine
code.
•The1
st
byte:Op-code,whichspecifiesthe
operationtobeperformed.
•The2
nd
byte:8-bitoperand,whichiseitheran
8-bitnumberoranaddress.
•Eg:MVIA,05H;ADI0FH;IN50Hetc.
▫ MVIA05H
18
SSP/EC-403/2021
Opcode 8-bit Operand
Two Byte

Three-Byte Instructions
•Instructionrequirethreebytesinmachinecode.
•1
st
byte:Op-code,whichspecifiestheoperation
tobeperformed.
•2
nd
and3
rd
byte:16-bitoperand,whichiseither
an16-bitnumberoranaddress.
•Eg:LXIH8500H;JMP6900H,STA7900Hetc.
▫ STA79 00H
19
SSP/EC-403/2021
Opcode Higher order
8-bit operand
Lower order
8-bit operand
Three Byte

Classification of Instruction Set
•BasedonFunctionality:
▫DataTransferInstruction
▫ArithmeticInstructions
▫LogicalInstructions
▫BranchingInstructions
▫Stack/IOandM/CControlInstructions
20
SSP/EC-403/2021

Data Transfer Instructions
•These instructions move data between registers,
or between memory and registers.
•These instructions copy data from source to
destination.
•Sometime data stored directly in designated
location.
•While copying, the contents of source are not
modified.
21
SSP/EC-403/2021

Data Transfer Instructions
•MOV B,C: Copy from source to destination.
•MVIC,05H: Load register C with the data 05H.
•LXI H,9000H: Load 9000H in HL register pair.
SSP/EC-403/2021
22
SourceDestination 88H88H
[C] 05H05H
[B] [C]
[H] [L]
90 00H9000

Data Transfer Instructions
•MVI M,25H: Put the data in memory location.
•MOV M,C: Copy the value of C to memory
location.
•MOV C,M:
SSP/EC-403/2021
23
[M]25H 25H
[M]
C80H
80H

Data Transfer Instructions
•LDA8800H:Loadthecontentofmemorylocation8800Hin
theAccumulator.
•STA2500H:Thecontentsofaccumulatorarecopiedintothe
memorylocationspecifiedbytheoperand.
•STAXB:Thecontentsofaccumulatorarecopiedintothe
memorylocationspecifiedbythecontentsoftheregisterpair.
SSP/EC-403/2021
24
[8800]
AF[A]AF
[A][2500] 5858
[B] [C]
8589
[8589] [A]
6B6B

Data Transfer Instructions
Op-codeOperand Description
MOV Rd, Rs
M, Rs
Rd, M
Copy from source to destination.
MVI R,8 bit dataLoad register with 8bit data.
LDA 16-bit
address
Load the content of memory location in
the Accumulator.
STA 16 bit
address
The contents of accumulator are copied
into the memory location specified by
the operand.
STAX Rp The contents of accumulator are copied
into the memory location specified by
the contents of the register pair.
LXI Rp,16 bit
data
Load the register pair immediate.
25
SSP/EC-403/2021

Arithmetic Instructions
•Oneofthedatausedinarithmeticoperationsis
storedinaccumulator.
•Resultisstoredinaccumulator.
•Arithmeticoperationscannotbeexecutedwithout
Acc.
•Theseinstructionsperformtheoperationslike:
▫Addition
▫Subtraction
▫Increment
▫Decrement
26
SSP/EC-403/2021

Addition
•Any8-bitnumber,orthecontentsofregister,orthecontentsof
memorylocationcanbeaddedtothecontentsofaccumulator.
•Theresult(sum)isstoredintheaccumulator.
•Notwoother8-bitregisterscanbeaddeddirectly.
Op-code Operand Description
ADD R
M
Thecontentsofregisterormemoryareaddedto
thecontentsofaccumulator.
ADC R
M
Addwithcarry.Thecarrygeneratedfromthe
previousoperationisincorporatedinthis
addition.
ADI 05H The8-bitdataisaddedtothecontentsof
accumulator.
DAD B The16-bitcontentsoftheregisterpairareadded
tothecontentsofH-Lpair.Theresultisstoredin
H-Lpair.Iftheresultislargerthan16bits,then
CYisset.
DAA Decimaladjustafteraddition.Itonlyusedafter
addition.Thisinstructiondoesn'thaveany
operand.ItisonlyimpliedonAcc.
27
SSP/EC-403/2021

Subtraction
•Any 8-bit number, or the contents of register, or the
contents of memory location can be subtracted from
the contents of accumulator.
•The result is stored in the accumulator.
•Subtraction is performed in 2’s complement form.
•If the result is negative, it is stored in 2’s
complement form.
•No two other 8-bit registers can be subtracted
directly.
•Example:SUB B, SUB M, SUI data
28
SSP/EC-403/2021

Increment / Decrement
•The8-bitcontentsofaregisteroramemorylocationcan
beincrementedordecrementedby1.
•The16-bitcontentsofaregisterpaircanbeincremented
ordecrementedby1.
•Incrementordecrementcanbeperformedonany
registeroramemorylocation.
Op-codeOperand Description
INR R
M
Thecontentsofregisterormemory
locationareincrementedby1..The
resultisstoredinthesameplace.
INX R Thecontentsofregisterpairare
incrementedby1.Theresultis
storedinthesameplace.
29
SSP/EC-403/2021

Logical Instructions
•Theseinstructionsperformlogicaloperationson
datastoredinregisters,memoryandstatusflags
withthecontentsofaccumulator.
•Theresultisstoredinaccumulator.
•Thelogicaloperationsare:
▫AND
▫OR
▫XOR
▫Rotate
▫Compare
▫Complement
30
SSP/EC-403/2021

AND, OR, XOR
Op-codeOperand Description
ANA R
M
Thecontentsoftheaccumulatorarelogically
ANDedwiththecontentsofregisterormemory.
Theresultisplacedintheaccumulator.
ANI 8-bit dataThecontentsoftheaccumulatorarelogically
ANDedwiththe8-bitdata.Theresultisplaced
intheaccumulator.
ORA R
M
ThecontentsoftheaccumulatorarelogicallyOR
edwiththecontentsoftheregisterormemory.
Theresultisplacedintheaccumulator.
XRI 8-bit dataThecontentsoftheaccumulatorareXORed
withthe8-bitdata.Theresultisplacedinthe
accumulator.
31
SSP/EC-403/2021

Rotate
•Each bit in the accumulator can be shifted either left or
right to the next position.
•RLC: Each binary bit of the accumulator is rotated left by
one position.
•RAL:Each binary bit of the accumulator is rotated left by
one position through the Carry flag.
SSP/EC-403/2021
32
76543210
C
Accumulator
76543210
C
Accumulator

Rotate Cont..
▫RRC:Eachbinarybitoftheaccumulatorisrotated
rightbyoneposition.
•RAR:Eachbinarybitoftheaccumulatorisrotatedright
byonepositionthroughtheCarryflag.
SSP/EC-403/2021
33
76543210
Accumulator
76543210
Accumulator
C
C

Rotate
Op-codeOperand Description
RLC None Eachbinarybitoftheaccumulatorisrotatedleft
byoneposition.BitD7isplacedinthepositionof
D0aswellasintheCarryflag.CYismodified
accordingtobitD7.
RAL None Eachbinarybitoftheaccumulatorisrotatedleft
byonepositionthroughtheCarryflag.BitD7is
placedintheCarryflag,andtheCarryflagis
placedintheleastsignificantpositionD0.CYis
modifiedaccordingtobitD7.
RRC None Eachbinarybitoftheaccumulatorisrotatedright
byoneposition.BitD0isplacedinthepositionof
D7aswellasintheCarryflag.CYismodified
accordingtobitD0.
RAR None Eachbinarybitoftheaccumulatorisrotatedright
byonepositionthroughtheCarryflag.BitD0is
placedintheCarryflag,andtheCarryflagis
placedinthemostsignificantpositionD7.CYis
modifiedaccordingtobitD0.
34

Compare
•Any 8-bit data, or the contents of register, or
memory location can be compares for:
▫Equality
▫Greater Than
▫Less Than
with the contents of accumulator.
•The result is reflected in status flags.
35
SSP/EC-403/2021

Compare
Op-codeOperand Description
CMP R
M
Thecontentsoftheoperand(registeror
memory)arecomparedwiththecontents
oftheaccumulator.Bothcontentsare
preserved.
Theresultofthecomparisonisshownbysettingtheflags
ofthePSWasfollows:
if(A)<(reg/mem):carryflagisset
if(A)=(reg/mem):zeroflagisset
if(A)>(reg/mem):carryandzeroflagsarereset.
36
SSP/EC-403/2021

Compare
Op-codeOperand Description
CPI 8-bit dataThe8-bitdataiscomparedwiththecontents
ofaccumulator. Thevaluesbeing
comparedremainunchanged.
Theresultofthecomparisonisshownbysettingtheflags
ofthePSWasfollows:
if(A)<data:carryflagisset
if(A)=data:zeroflagisset
if(A)>data:carryandzeroflagsarereset
37
SSP/EC-403/2021

Complement
•Thecontentsofaccumulatorcanbecomplemented.
•Each0isreplacedby1andeach1isreplacedby0.
Op-codeOperand Description
CMA None Thecontentsoftheaccumulatorare
complemented.Noflagsareaffected.
CMC None TheCarryflagiscomplemented.No
otherflagsareaffected.
STC None TheCarryflagissetto1.Nootherflags
areaffected.
38
SSP/EC-403/2021

Stack/IO and M/C Control
•Stack:
▫PUSH
▫POP
•I/O:
▫IN
▫OUT
•M/C Control:
▫RIM
▫SIM
▫NOP
▫HLT
▫DI
▫EI
SSP/EC-403/2021
39

I/O Operation
•DatawillonlyabletotransferviaAcc.
•Processordealswithonedeviceatatime.
•EachandeveryI/Odevicesaresignifiedby
address.
•TheI/Oaddressareknownasport.
•Itis8-bitaddress.
•Wecanattach2
8
ie.256deviceswitha
processor.
•IN40H:A[40H]
•OUT50HA[50H]
SSP/EC-403/2021
40

Control Instructions
•The control instructions control the operation of
microprocessor.
OpcodeDescription Status Flags
NOP None Nooperationisperformed.The
instructionisfetchedanddecoded
butnooperationisexecuted.
HLT None TheCPUfinishesexecutingthecurrent
instructionandhaltsanyfurther
execution.Aninterruptorresetis
necessarytoexitfromthehaltstate.
DI None Disableinterrupt.Theinterruptenable
flip-flopisresetandalltheinterrupts
excepttheTRAParedisabled.
41
SSP/EC-403/2021

Branching Instructions
•Thebranchinginstructionalterthenormalsequential
flow.Eg.JMP,CALL,RET,
•Theseinstructionsaltereitherunconditionallyor
conditionally.
Op-codeOperand Description
JMP 16-bit
address
Jump unconditionally.The program
sequenceistransferredtothememory
locationspecifiedbythe16-bitaddressgiven
intheoperand.
Jx 16-bit
address
Jumpconditionally.Theprogramsequence
istransferredtothememory location
specifiedbythe16-bitaddressgiveninthe
operandbasedonthespecifiedflagofthe
PSW.
42
SSP/EC-403/2021

Jump Conditionally
Opcode Description Status Flags
JC Jump if Carry CY = 1
JNC Jump if No Carry CY = 0
JP Jump if Positive S = 0
JM Jump if Minus S = 1
JZ Jump if Zero Z = 1
JNZ Jump if No Zero Z = 0
JPE Jump if Parity
Even
P = 1
JPO Jump if Parity
Odd
P = 0
43
SSP/EC-403/2021

SSP/EC-403/2021
44
Tags