0% found this document useful (0 votes)
144 views22 pages

8085 Microprocessor Instructions

The 8085 microprocessor has an 8-bit opcode and can support 256 opcodes, though only 246 are implemented. The document then lists and describes various data transfer and arithmetic instructions of the 8085 including: MOV, MVI, LDA, LXI, LHLD, STA, STHL, XCHG, SPHL, XTHL, PUSH, POP, IN, OUT, ADD, ADC, ADI, ACI, DAD, INR and SUB.
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)
144 views22 pages

8085 Microprocessor Instructions

The 8085 microprocessor has an 8-bit opcode and can support 256 opcodes, though only 246 are implemented. The document then lists and describes various data transfer and arithmetic instructions of the 8085 including: MOV, MVI, LDA, LXI, LHLD, STA, STHL, XCHG, SPHL, XTHL, PUSH, POP, IN, OUT, ADD, ADC, ADI, ACI, DAD, INR and SUB.
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

Instruction set of 8085 Microprocessors:

the opcode is 1byte or 8 bit length, thus 256distinct opcodes are


possible; However 246 opcodes are implemented in 8085

Types:
Data transfer Instructions LHLD, 5566H
Opcode Operand Meaning Explanation

Rd, Sc Copy from the This instruction copies the contents of the source register into the destination register without any alteration.
MOV M, Sc source (Sc) to the Example − MOV B, D
Dt, M destination(Dt) MOV M, B; MOV B, M

The 8-bit data is stored in the destination register or memory.


Rd, data Move immediate
MVI Example − MVI B, 55h
M, data 8-bit
MVI M, 55h
The contents of a memory location, specified by a 16-bit address in the operand, are copied to the accumulator.
16-bit Load the
LDA Example − LDA 2034h
address accumulator

Load the The contents of the designated register pair point to a memory location. This instruction copies the contents of
B/D Reg.
LDAX accumulator that memory location into the accumulator.
pair
indirect Example − LDAX B
The instruction loads 16-bit data in the register pair designated in the register or the memory.
Reg. pair, Load the register
LXI Example − LXI H, 3225h
16-bit data pair immediate

The instruction copies the contents of the memory location pointed out by the address into register L and copies
16-bit Load H and L
LHLD the contents of the next memory location into register H.
address registers direct
Example − LHLD 3225h [content of 3225h and 3226h will load to L and H reg respectively]
Data transfer Instructions: SHLD 3455H
Opcode Operand Meaning Explanation

The contents of the accumulator are copied into the memory location specified by the operand.
16-bit This is a 3-byte instruction, the second byte specifies the low-order address and the third byte specifies the high-
STA 16-bit address
address order address.
Example − STA 3255h
Store the The contents of the accumulator are copied into the memory location specified by the contents of the operand.
16-bit
STAX accumulator Example − STAX B
address
indirect
The contents of register L are stored in the memory location specified by the 16-bit address in the operand and the
contents of H register are stored into the next memory location by incrementing the operand.
16-bit Store H and L
SHLD This is a 3-byte instruction, the second byte specifies the low-order address and the third byte specifies the high-
address registers direct
order address.
Example − SHLD 3225h
The contents of register H are exchanged with the contents of register D, and the contents of register L are
Exchange H and L
XCHG None exchanged with the contents of register E.
with D and E
Example − XCHG
Copy H and L The instruction loads the contents of the H and L registers into the stack pointer register. The contents of the H
SPHL None registers to the register provide the high-order address and the contents of the L register provide the low-order address.
stack pointer Example − SPHL
The contents of the L register are exchanged with the stack location pointed out by the contents of the stack
Exchange H and L pointer register.
XTHL None
with top of stack The contents of the H register are exchanged with the next stack location (SP+1).
Example − XTHL
Data transfer Instructions
Opcode Operand Meaning Explanation

The contents of the register pair designated in the operand are copied onto the stack in the following sequence.
The stack pointer register is decremented and the contents of the high order register (B, D, H, A) are copied into
Push the register
that location.
PUSH Reg. pair pair onto the
The stack pointer register is decremented again and the contents of the low-order register (C, E, L, flags) are
stack
copied to that location.
Example − PUSH B
The contents of the memory location pointed out by the stack pointer register are copied to the low-order register
(C, E, L, status flags) of the operand.
Pop off stack to The stack pointer is incremented by 1 and the contents of that memory location are copied to the high-order
POP Reg. pair
the register pair register (B, D, H) of the operand.
The stack pointer register is again incremented by 1.
Example – POP B
Output the data The contents of the accumulator are copied into the I/O port specified by the operand.
from the Example − OUT 59h
8-bit port
OUT accumulator to a
address
port with 8bit
address
Input data to The contents of the input port designated in the operand are read and loaded into the accumulator.
8-bit port accumulator from Example – IN 57h
IN
address a port with 8-bit
address
Opcode Operand
Arithmetic Instructions
Meaning
INX B
Explanation

ADD R Add register or memory, to the The contents of the register or memory are added to the contents of the Accumulator and the
M Accumulator result is stored in the Accumulator.
Example − ADD B.
ADC R Add register to the Accumulator The contents of the register or memory & M the Carry flag are added to the contents of the
M with carry Accumulator and the result is stored in the Accumulator.
Example − ADC B
ADI 8-bit data Add the immediate to the The 8-bit data is added to the contents of the Accumulator and the result is stored in the
Accumulator Accumulator.
Example − ADI 55h
ACI 8-bit data Add the immediate to the The 8-bit data and the Carry flag are added to the contents of the Accumulator and the result is
Accumulator with carry stored in the Accumulator.
Example −ACI 55h
DAD Reg. pair Add the register pair to H and L The 16-bit data of the specified register pair are added to the contents of the HL register.
registers Example − DAD B

INR R Increment the register or the The contents of the designated register or the memory are incremented by 1 and their result is
M memory by 1 stored at the same place.
Example − INR B
INX R Increment register pair by 1 The contents of the designated register pair are incremented by 1 and their result is stored at the
same place.
Example − INX B
SUB R
Arithmetic Instructions SUB C
Subtract the register or The contents of the register or the memory are subtracted from the contents of the Accumulator, and the result
M the memory from the is stored in the Accumulator.
Accumulator Example − SUB B
SBB R Subtract the source and The contents of the register or the memory & M the Borrow flag are subtracted from the contents of the Accumulator
M borrow from the and the result is placed in the Accumulator.
Accumulator Example − SBB B
SUI 8-bit data Subtract the immediate The 8-bit data is subtracted from the contents of the Accumulator & the result is stored in the Accumulator.
from the Accumulator Example −SUI 55h

SBI 8-bit data Subtract the immediate The 8-bit data is subtracted to the contents of the Accumulator and the result is stored in the Accumulator.
from the Accumulator with Example −SBI 55h
borrow
DCR R Decrement the register or The contents of the designated register or memory are decremented by 1 and their result is stored at the same place.
M the memory by 1 Example − DCR B

DCX R Decrement the register pair The contents of the designated register pair are decremented by 1 and their result is stored at the same place.
by 1 Example − DCX B

DAA None Decimal adjust The contents of the Accumulator are changed from a binary value to two 4-bit BCD digits.
Accumulator If the value of the low-order 4-bits in the Accumulator is greater than 9 or if AC flag is set, the instruction adds 6 to the
low-order four bits.
If the value of the high-order 4-bits in the Accumulator is greater than 9 or if the Carry flag is set, the instruction adds 6
to the high-order four bits.
Example − DAA
Logical Instructions
Opcode Operand Meaning Explanation

CMP R Compare the register or memory with The contents of the operand (register or memory) are M compared with the contents of
M the Accumulator the Accumulator.

CPI 8-bit data Compare immediate with the The second Byte data is compared with the contents of the Accumulator.
Accumulator

ANA R Logical AND register or memory with The contents of the Accumulator are logically AND with M the contents of the register or
M the Accumulator memory, and the result is placed in the Accumulator.

ANI 8-bit data Logical AND immediate with the The contents of the Accumulator are logically AND with the 8-bit data and the result is
Accumulator placed in the Accumulator.

XRA R Exclusive OR register or memory with The contents of the Accumulator are Exclusive OR with M the contents of the register or
M the Accumulator memory, and the result is placed in the Accumulator.

XRI 8-bit data Exclusive OR immediate with the The contents of the Accumulator are Exclusive OR with the 8-bit data and the result is
Accumulator placed in the Accumulator.

ORA R Logical OR register or memory with The contents of the Accumulator are logically OR with M the contents of the register or
M the Accumulator memory, and result is placed in the Accumulator.

ORI 8-bit data Logical OR immediate with the The contents of the Accumulator are logically OR with the 8-bit data and the result is
Accumulator placed in the Accumulator.
Logical Instructions
Opcode Operand Meaning Explanation

RLC None Rotate the Accumulator left Each binary bit of the Accumulator is rotated left by one position. Bit D7 is placed in the
position of D0 as well as in the Carry flag. CY is modified according to bit D7.

RRC None Rotate the Accumulator right Each binary bit of the Accumulator is rotated right by one position. Bit D0 is placed in the
position of D7 as well as in the Carry flag. CY is modified according to bit D0.

RAL None Rotate the Accumulator left through Each binary bit of the Accumulator is rotated left by one position through the Carry flag.
carry Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least significant
position D0. CY is modified according to bit D7.

RAR None Rotate the Accumulator right through Each binary bit of the Accumulator is rotated right by one position through the Carry flag.
carry Bit D0 is placed in the Carry flag, and the Carry flag is placed in the most significant
position D7. CY is modified according to bit D0.

CMA None Complement Accumulator The contents of the Accumulator are complemented. No flags are affected.

CMC None Complement carry The Carry flag is complemented. No other flags are affected.

STC None Set Carry Set Carry


Branch Instructions: 2000: JNC 2790h
Branch Instructions: CALL and Return a*b+C*d+e*f
Branch Instructions: NOP
Addressing Modes of 8085
• Immediate addressing mode:
• Register addressing mode
• Direct addressing mode
• Indirect addressing mode
• Implied addressing mode
Addressing Modes of 8085
execution of instruction in 8085 from memory

2C00: LXIH 552Fh


2C03: MOV A,M

2C00 21
2C01 2F
2C02 55
XX
Store an 8 bit data in memory
MVI A, 24H – store 24H in the accumulator.
STA 1423H – copy the contents of accumulator to memory location 1423H.
HLT – stop the execution.

2000 5F h (MVI A (op-code)


2001 24 h
2002 53 h (STA (op-code)
2003 23 h
2004 14 h
2005 76 h (HLT (op-code)
8085 program to add two 8 bit data numbers 8085 program to sub two 8 bit data
numbers
0200 H LXI H, 1500H – store the address of first number
(1500 H) in HL register pair.
0200H LXI H, 1500H

0203 H MOV A, M – copy the contents of memory MOV A, M


0203H
location to accumulator

0204 H INX H – increments the contents of HL 0204H INX H


register pair. HL now points to 1501H
0205H SUB M
0205 H ADD M – Add first operator in the accumulator
with the second operator in memory
location 1501H. 0206H INX H

0206 H INX H – HL now points to 1502H.


0207H MOV M, A
0207 H MOV M, A – store result in accumulator at location
1502H.
0208H HLT
0208 H HLT – stop the execution.
8085 program to find 1s compliment of a number
LDA 1500H
CMA
STA 1501H
HLT

8085 program to find 2s compliment of a number


LDA 1500 H
CMA
ADI, 01 H
STA 1501 H
HLT
8085 Assembly language program to add N number of 8-byte numbers Multiply two 8-bit nos stored in mem. Loc. and store the 16-bit result
Address HEX Labels Mnemonics Comments
Address HEX Codes Labels Mnemonics Comments
Codes
F000 21, 00, 80 LXI H, 8000H Load the address to get a count of F000 21, 00, 80 LXI Load first operand address
numbers H,8000H
F003 4E MOV C, M Load C with the count value
F003 46 MOV B, M Store first operand to B
F004 21,10, 80 LXI H, 8010H Load HL with the starting address
F004 23 INX H Increase HL pair
F007 AF XRA A Clear Accumulator F005 AF XRA A Clear accumulator
F008 5F MOV E, A Clear the E register also F006 4F MOV C, A Store 00H at register C
F009 86 LOOP ADD M Add Memory content with
Accumulator F007 86 LOOP ADD M Add memory element with Acc

F00A D2, 0E, F0 JNC SKIP When the carry is false, skip next F008 D2, 0C, F0 JNC SKIP if Carry flag is 0, skip next task
task
F00B 0C INR C Increase C when carry is 1
F00D 1C INR E Increase E, when the C flag is set
F00C 05 SKIP DCR B Decrease B register
F00E 0D SKIP INX H Point to next location
F00D C2, 07, F0 JNZ LOOP Jump to loop if Z flag is not 1
F00F 23 DCR C Decrease C register by 1
F010 C2, 09, F0 JNZ LOOP When Zero is false, go to LOOP F010 21, 50, 80 LXI Load Destination address
H,8050H
F013 21, 00, 90 LXIH, 9000H Load address to store the result
F013 71 MOV M, C Store C content into memory
F016 77 MOV M, A Save accumulator content
F014 23 INX H Increase HL Pair
F017 23 INX H Increase HL pair
F015 77 MOV M, A Store Acc content to memory
F018 73 MOV M, E Store carry
F019 76 HLT Terminate the program F016 76 HLT Terminate the program
Transfer a block of ten 8-bit number from source memory Write a program to
locations starting from 45001H to destination locations starting multiply an 8-bit number
from 5501H by 4

LXI H, 4500H :"Initialize number of data to be transferred"


MOV A, M
MOV C, A :"Initialize counter"
INX H
LXI D, 5501H :"Initialize pointer"
BACK: MOV A, M :"Get the number"
STAX D
INX H :"increment pointer"
INX D :"increment pointer"
DCR C :"Decrement counter"
JNZ BACK :"if counter 0 repeat"
HLT :"Terminate program execution"
Calculate the sum of even numbers from a series of numbers Write a program to count
number of l’s in the
LDA 2200H contents of D register and
MOV C, A :"Initialize counter" store the count in the B
MVI B, 00H :"sum = 0" register.
LXI H, 2201H :"Initialize pointer" MVI B, 00H
BACK: MOV A, M :"Get the number" MVI C, 08H
ANI 0lH :"Mask Bit l to Bit7" MOV A, D
JNZ SKIP :"Don’t add if number is ODD" BACK: RAR
MOV A, B :"Get the sum" JNC SKIP
ADD M :"SUM = SUM + data" INR B
MOV B, A :"Store result in B register" SKIP: DCR C
SKIP: INX H :"increment pointer" JNZ BACK
DCR C :"Decrement counter" HLT
JNZ BACK :"if counter 0 repeat"
STA 2210H :"store sum"
HLT :"Terminate program execution"
Separate even numbers from given numbers Search a byte in a given number
Search the given byte in the list of 50 numbers stored in the consecutive memory locations and
store the address of memory location in the memory locations 2200H and 2201H. Assume byte
is in the C register and starting address of the list is 2000H. If byte is not found store 00 at
2200H and 2201H.
LXI H, 2200H :"Initialize memory pointer l" LX I H, 2000H :"Initialize memory pointer 52H"

LXI D, 2300H :"Initialize memory pointer2" MVI B, 52H :"Initialize counter"


MVI C, 32H :"Initialize counter" BACK: MOV A, M :"Get the number"
BACK:MOV A, M :"Get the number" CMP C :"Compare with the given byte"

ANI 0lH :"Check for even number" JZ LAST :"Go last if match occurs"
JNZ SKIP :"If ODD, don’t store" INX H :"Increment memory pointer"

MOV A, M :"Get the number" DCR B :"Decrement counter"


STAX D :"Store the number in result list" JNZ B :"If not zero, repeat"
INX D :"Increment pointer 2" LXI H, 0000H
SKIP: INX H :"Increment pointer l" SHLD 2200H
DCR C :"Decrement counter" JMP END :"Store 00 at 2200H and 2201H"

JNZ BACK :"If not zero, repeat" LAST: SHLD 2200H :"Store memory address"

HLT END: HLT :"Stop"


Assignment:

• Write a program to find the factorial of a number


• Find 1+2+3+………+n
• Convert binary number to decimal
• Find the greatest/smallest number from a set of numbers
• Arrange number in ascending/descending order
• Find the square of a number
• Find the square root of a number from a look up table
• …………

You might also like