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

MPI GTU Study Material Presentations Unit-4 17032021071018AM

The document provides an overview of the Assembly Language Programming unit in a Microprocessor and Interfacing course, detailing the topics covered, including the hierarchy of languages, assembly language tools, and classification of 8085 instructions. It emphasizes the importance of learning assembly language for system software implementation and efficiency in programming. The document also outlines the structure of assembly language instructions and the role of various programming tools such as assemblers and linkers.

Uploaded by

abbaria2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views132 pages

MPI GTU Study Material Presentations Unit-4 17032021071018AM

The document provides an overview of the Assembly Language Programming unit in a Microprocessor and Interfacing course, detailing the topics covered, including the hierarchy of languages, assembly language tools, and classification of 8085 instructions. It emphasizes the importance of learning assembly language for system software implementation and efficiency in programming. The document also outlines the structure of assembly language instructions and the role of various programming tools such as assemblers and linkers.

Uploaded by

abbaria2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 132

Microprocessor and Interfacing

(MPI)
GTU # 3160712

Unit-4:
Assembly
Language
Programming Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Basics Prof. Swati R Sharma


Computer Engineering
Department
PART-I: 8085 Instruction
Darshan Institute Set
of Engineering & Technology, Rajkot
[email protected]
(O) 9727747317
Subject Overview
Positive Vibes:MPI is the interesting, easiest and scoring
Sr. No. Unit subject.
%
Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 12%
4 Assembly Language Programming 13%
Basics
5 8085 Assembly Language Programs 12%
6 Stack & Subroutines 13%
7 I/O Interfacing 20%
8 Advanced Microprocessors 15%

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 2


 Looping
Topics to be covered
Positive Vibes:MPI is the interesting, easiest and scoring
 Assembly Language Programming subject.

Basics
 Hierarchy of Languages
 Compilers and Assemblers
 Instructions and Machine Language
 Advantages of High-Level Languages
 Why to Learn Assembly Language?
 Assembly Language Programming
Tools
 Classification of 8085 Instructions
 Based on Byte Size
 Based on Function
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Hierarchy of Languages
Hierarchy of Languages
Application Positive Vibes:MPI is the interesting, easiest and scoring

Program subject.

High Level
Machine Independent Language High Level Language
• Assembly
Machine Specific Assembly Low Level Language
language is a
Language low-level
1100
MOV 1011 Machine programming
• language
Native to a
BL,05h 1100 Language
ADD CL 1110 processor:for a
designed
MUL BH 0100 executed
specific type of
1111 Micro Program directly by
processor.
Control hardware
• Uses symbolic
• names
Instructions to
Hardware consist of
represent
binary code:
operations,
1s and 0s and
registers
memory
Prof. Swati R Sharma
locations.
Unit 4 – Assembly Language Basics 5
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Compilers and
Assemblers
Compilers and Assemblers
High Level Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Language

Compil
er

Compil Assembly
er Language
Assemb
ler

Machine
Language
Compilers translate high-level programs
Assemblers to assembly code to
translates
machine code machine code
either directly, or Indirectly via an assembler

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 7


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instructions and
Machine Language
Instructions and Machine Language
 Each command of a program is called an instruction (it instructs the
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

computer, what to do?).


 Computers only deal with binary data, hence the instructions must be in
binary format (0’s and 1’s).
 Therefore, each Opcode is having unique bit pattern of (0’s and 1’s).

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 9


Instruction Fields
 Assembly language instructions usually are made up of several fields.
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

 Each field specifies different information.


The major two fields are:
1. Opcode: Operation code that specifies operation to be performed.
Each operation has its unique opcode.
2. Operands: Fields which specify, where to get the source and destination operands
for the operation specified by the opcode.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 10


Instruction Fields
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Opcod Operand
e
MOV Rd, Rs
M, Rs
R, M

Rd  Destination Register
Rs  Source Register
M  Memory

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 11


Translating Languages
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

English: Sum of A and B

High-Level Language: A + B

A statement in a high-level language is


translated typically into several machine-level
instructions
Assembly Language: Machine
MVI A,02 Language:
MVI B,03 1001 1011 0010
ADD B 1001 1001 0011
1011 0011 0010

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 12


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Advantages of High-
Level Languages
Advantages of High-Level Languages
 Program development is faster Positive Vibes:MPI is the interesting, easiest and scoring
subject.
 High-level statements: fewer instructions to code.
 Program maintenance is easier
 As Higher Level Language contains fewer instruction code.
 Programs are portable
 Contain few machine-dependent details.
 Can be used with little or no modifications on different machines.
 Compiler translates to the target machine language.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 14


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Why to Learn Assembly


Language?
Why to Learn Assembly Language?
 Accessibility to system hardware Positive Vibes:MPI is the interesting, easiest and scoring
subject.
 Assembly Language is useful for implementing system software.
 It is also useful for small embedded system applications.
 Space and Time efficiency
 Understanding sources of program efficiency.
 Tuning program performance.
 Writing compact code.
 It is helpful for
 Compiler writing
 Programming microcontrollers
 Device drivers
 System design
 Low-level numeric routines

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 16


Why to Learn Assembly Language?
 Writing assembly programs gives the computer designer, deep Positive Vibes:MPI is the interesting, easiest and scoring
subject.
understanding of the instruction set and how to design.
 To be able to write compilers for HLL (Higher Level Language), we need to
be expert with the machine language. Assembly programming provides
such experience.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 17


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Assembly Language
Programming Tools
Assembly Language Programming Tools
1. Assembler Positive Vibes:MPI is the interesting, easiest and scoring
subject.

2. Linker
3. Debugger
4. Editor

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 19


Assembler
 An assembler is a program that converts programs written in assemblyPositive Vibes:MPI is the interesting, easiest and scoring
subject.
language into object files(machine language).
 Popular assemblers have emerged over the years for the Intel family of
processors. These include …
 TASM (Turbo Assembler from Borland).
 NASM (Net wide Assembler for both Windows and Linux), and
 GNU assembler distributed by the free software foundation.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 20


Linker
 A linker program is required to produce executable files. Positive Vibes:MPI is the interesting, easiest and scoring
subject.

 It combines program's object file created by the assembler with other


object files and link libraries, to produces a single executable program.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 21


Assembly Language Programming Tools
Positive Vibes:MPI is the interesting, easiest and scoring
Assemble
subject.and Link Process

Source Object
File Assembler File

Source Object Executable


File Assembler File Linker
File

Link
Source Object
Assembler Libraries
File File

A project may consist of multiple source files


Assembler translates each source file separately into an
object file
Linker links all object files together with link libraries
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 22
Debugger
 Allows you to trace the execution of a program. Positive Vibes:MPI is the interesting, easiest and scoring
subject.

 Allows you to view code, memory, registers etc.


 Example: WinDbg, GDB - the GNU debugger, etc.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 23


Editor
 Allows to create assembly language source files. Positive Vibes:MPI is the interesting, easiest and scoring
subject.

 Some editors provide syntax highlighting features and can be customized


as per programming environment.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 24


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Classification of
8085 Instructions
Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Classification of 8085 instructions
 An instruction is a binary pattern designed inside a microprocessor to
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
perform a specific function.
 Each instruction is represented by an 8-bit binary value called Op-Code.
 The entire group of instructions that a microprocessor supports is known
as an Instruction Set.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 27


Classification of 8085 instructions
Instruction Set Positive Vibes:MPI is the interesting, easiest and scoring
subject.
 It is the set of instructions that the microprocessor can understand.
Opcode
 Known as Operation Code.
 This required field contains the mnemonic operation code for the 8085 instruction.
Operand
 The operand field identifies the data to be operated on by the specified opcode.
 Some instructions require no operands, while others require one or two operands.

MVI D, 8BH

Opco Opera
de nd

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 28


Classification of 8085 instructions
General Terms Positive Vibes:MPI is the interesting, easiest and scoring
subject.

R 8085 8-bit register (A, B, C, D, E, H,


M L)
Memory
Rs Register Source
Rd Register Destination
Rp Register Pair (BC, DE, HL)

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 29


One-byte Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
One-byte instructions includes Opcode and Operand in the same
subject.

byte.
Instruction Binary Code Hexa Code
Opcode Operand
MOV C,A 0100 1111 4FH
ADD B 1000 0000 80H
CMA 0010 1111 2FH

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 30


List of one-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
Sr Instruction Sr. Instruction Sr. Instruction Sr. Instruction
subject.

.
1 MOV 13 SBB R/M 25 RNZ 37 CMA
dest.,src
2 LDAX RP 14 INR R/M 26 RPE 38 CMC
(B/D)
3 STAX RP 15 INX RP 27 RPO 39 STC
4 XCHG 16 DCR R/M 28 RST 0-7 40 NOP
5 SPHL 17 DCX RP 29 CMP R/M 41 HLT
6 XTHL 18 DAA 30 ANA R/M 42 DI
7 PUSH RP 19 RET 31 XRA R/M 43 EI
8 POP RP 20 RC 32 ORA R/M 44 RIM
9 ADD R/M 21 RNC 33 RLC 45 SIM
10 ADC R/M 22 RP 34 RRC
11 DAD 23 RM 35 RAL
12 SUB R/M 24 RZ 36 RAR
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 31
Two-byte Instruction
In two-byte instruction, Positive Vibes:MPI is the interesting, easiest and scoring
subject.

1st Byte : Specifies Opcode


2nd Byte: Specifies Operand

Instruction Binary Code Hexa Code


Opcode Operand
MVI A,32H 0011 1110 3E: 1st Byte
0011 0010 32: 2nd Byte
MVI B,F2H 0011 1110 3E: 1st Byte
1111 0010 F2: 2nd Byte
IN 0AH 1101 1011 DB: 1st Byte
0000 1010 0A: 2nd Byte

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 32


List of two-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
Sr. Instruction subject.

1 MVI destination,8-bit
data
2 OUT 8-bit port address
3 IN 8-bit port address
4 ADI 8-bit data
5 ACI 8-bit data
6 SUI 8-bit data
7 SBI 8-bit data
8 CPI 8-bit data
9 ANI 8-bit data
10 XRI 8-bit data
11 ORI 8-bit data

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 33


Three-byte Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
In three-byte instruction, subject.

1st Byte: Specifies Opcode


2nd Byte: Specifies lower order 8-bit address
3rd Byte: Specifies higher order 8-bit address

Instruction Binary Code Hexa Code


Opcode Operand
LDA 2050H 0011 1010 3A: 1st Byte
0101 0000 50: 2nd Byte
0010 0000 20: 3rd Byte
JMP 2085H 1100 0011 C3: 1st Byte
1000 0101 85: 2nd Byte
0010 0000 20: 3rd Byte

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 34


List of three-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
Sr. Instruction Sr. Instruction subject.
1 LDA 16-bit 13 JPE 16-bit
address address
2 LXI Rp, 16-bit 14 JPO 16-bit
data address
3 LHLD 16-bit 15 CALL 16-bit
address address
4 STA 16-bit 16 CC 16-bit
address address
5 SHLD 16-bit 17 CNC 16-bit
address address
6 JMP 16-bit 18 CP 16-bit
address address
7 JC 16-bit 19 CM 16-bit
address address
8 JNC 16-bit 20 CZ 16-bit
address address
Prof. Swati R Sharma
9 JP 16-bit 21 CNZ 16-bit
Unit 4 – Assembly Language Basics 35
GTU Exam Questions
Positive Vibes:MPI is the interesting, easiest and scoring
S Questions subject.
Mar Yea
r ks r
1 Explain the functions of following instructions of 8085 – state the bytes occupied, 4 W’1
. number of Machine cycle required and T-States 8
1. LXI H, 2050H
2. MOV B,A
3. STA 5050H
4. ADD C
2 Explain the functions of following instructions of 8085 – state its 4 S’1
. number of bytes occupied, number of Machine cycle required and T-states. 9
1. MOV A,M
2. LXI H,1000H
3. DAA
3 4 W’1
. Explain One byte, Two byte, Three byte instruction. 9

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 36


Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Data Transfer
Instructions
Data Transfer Instructions
 Instructions copy data from source to destination. Positive Vibes:MPI is the interesting, easiest and scoring
subject.

 While copying, the contents of source is not modified.


 Data Transfer Instructions do not affect the flags.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 39


MOV: Move data from source to destination
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
MOV Rd, • This instruction copies the MOV B, C ; BC
Rs contents of the source MOV B,
MOV M, R register into the destination M;BM[HL]
MOV R, M register. MOV M, B; M[HL]B
• Contents of the source
register is not altered.
• If one of the operands is a
memory, its location is
specified by the contents of
the HL registers.
• one-byte instruction.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 40


MVI: Load 8-bit to Register/Memory
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e MVI d R, • The 8-bit data is stored in MVI B, 57H; B12
Data the destination register or MVI M, 12H ;
M, memory. M[HL]12
Data • If the operand is a memory
location, its location is
specified by the contents
of the HL registers.
• Two-byte instruction.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 41


Example: LDA Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
LDA
2050H
Register Memor
s y 02 2000
A
04 …
B C 0A ..
06 .
D E
0F 2049
H L 0D 205
05 0051
2
03 2052

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 42


LDA: Load Accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
LDA 16- • The contents of a memory LDA 2050H
bit location, specified by a 16-bit LDA 0006H
address in the operand, is
address copied to the accumulator.
• The contents of the source is
not altered.
• Three-byte instruction.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 43


LDAX: Load the accumulator indirect
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
LDAX Rp • The contents of a memory LDAX B ;
(B/D) location, specified by a 16-bit AM[BC]
address in the operand, is LDAX D ;
copied to the accumulator. AM[DE]
• The contents of the source is
not altered.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 44


Example: LDAX Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
LDAX B ; subject.

AM[BC]
Register Memor
s y 02 0001
A
04 0002
B 00 06 C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 45


LXI: Load the immediate register pair
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operand
e LXI H, 2034H
LXI Rp, 16- The instruction loads
bit immediate 16-bit data
Data into register pair.
Register
s
A
B
D
H 20 34 L

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 46


STA: Store Accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
STA 16-bit The contents of accumulator is STA 0002H
copied into the memory location
16-bit memory address
address specified by the operand.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 47


STAX: Store Accumulator Indirect
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d STAX B;M[BC]A
STAX Rp The contents of accumulator is
copied into memory location
specified by the contents of the
operand (register pair). The
contents of the accumulator is
not altered.
Register 02 0001Memor
s 04 0002y
A 0D 0A 0003
06 0004
B 00 06 C 0F 0005
D E 04 0006
05 0007
H L 03 0008
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 48
Example: LHLD Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
LHLD subject.

0006H
Register Memor
s y
02 0001
A
04 0002
B C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 49


LHLD: Load H and L registers direct
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
LHLD 16- • The instruction copies LHLD 2050H
bit contents of the memory LHLD 0006H
location pointed out by the
address address into register L and
copies the contents of the
next memory location into
register H.
• The contents of source
memory locations is not
altered.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 50


SHLD: Store H and L registers direct
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
eSHLD d 16- The contents of register L is SHLD 0002H
bit stored in memory location
specified by the 16-bit address
address in the operand and the contents
of H register is stored into the
next memory location by
incrementing the operand.
Memor
y 0001
0002
H A2
A2 D3 L 0003
0004

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 51


XCHG: Exchange H and L with D and E
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e XCHGd The contents of register H are XCHG
None exchanged with the contents of
register D, and the contents of
register L are exchanged with
the contents of register E.

D A2 03 E D D3 08 E
H D3 08 L H A2 03 L

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 52


SPHL: Copy H and L registers to stack pointer
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
eSPHL d
None The instruction loads the SPHL
contents of the H and L registers
into the stack pointer register,
the contents of H register
provide the high-order address
and the contents of L register
provide the low-order address.
The contents of the H and L
registers are not altered. SP
H A2 D3 L (16)

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 53


XTHL: Exchange H and L with top of stack
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
eXTHL d
None The contents of L register is XTHL
exchanged with stack location
pointed out by contents SP. The
contents of the H register are
exchanged with the next stack
location (SP+1).

Register Memor
s y 0001
3F 0002 SP
H A2 D3 L 0003
2C SP
0004

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 54


Example: PUSH Instruction
PUSH B Positive Vibes:MPI is the interesting, easiest and scoring
subject.
SP <- SP-1
SP <- B ;transfer high
order bit to TOS
SP <- SP-1
SP <- C ;transfer low
order bit to TOS
Register Memor
s SP y 23 0008
A
SP 06 0007
B 06 40 C SP 40 0006
D E 0005
0004
H L 0003
0002
0001

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 55


PUSH: Push the register pair onto the stack
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Opcod Operan
e d The contents of the register pair PUSH B
PUSH Rp
designated in the operand are
copied onto the stack in the
following sequence.
1. The SP register is
decremented and the
contents of the high order
register (B, D, H) are copied
into that location.
2. The SP register is
decremented again and the
contents of the low-order
register (C, E, L) are copied
to that location.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 56


Example: POP Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Register Memo
s SP ry03 0008
A
SP 06 0007
B 06 40 C SP 40 0006
D 0005
E
0004
H L 0003
0002
0001
POP B
C <- SP ; transfer to low order bit
from TOS
SP <- SP+1

B <- SP ; transfer to high order bit


from TOS
SP <- SP+1
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 57
POP: Pop off stack to the register pair
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcode Operand

POP Rp The contents of the memory POP B


location pointed out by the
stack pointer register are copied
to the low-order register (C, E, L)
of the operand.
1. The stack pointer is
incremented by 1 and the
contents of that memory
location are copied to the
high-order register (B, D, H)
of the operand.
2. The stack pointer register is
again incremented by 1.
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 58
OUT: Output from Accumulator to 8-bit port
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d OUT 0AH
OUT 8-bit The contents of the accumulator
port are copied into the I/O port
specified by the operand.
address

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 59


IN: Input data to accumulator from with 8-bit port
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d IN 0AH
IN 8-bit The contents of the input port
port designated in the operand are
read and loaded into the
address accumulator.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 60


1 MOV Dst,Src Copy content 1 Byte
2 MVI (R/M), 8-bit Load 8-bit to Register/Memory 2 Byte
3 Data
LDA 16-bit address Load Accumulator 3 Byte
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
4 LDAX Rp(B/D) Load the accumulator indirect 1 Byte
5 LXI Rp, 16-bit Data Load the register pair immediate 3 Byte
Data Transfer Instructions

6 STA 16-bit address Store Accumulator 3 Byte


7 STAX Rp Store Accumulator Indirect 1 Byte
8 LHLD 16-bit address Load H and L registers direct 3 Byte
9 SHLD 16-bit address Store H and L registers direct 3 Byte
1 XCHG None Exchange H and L with D and E 1 Byte
0
1 SPHL None Copy H and L registers to the stack 1 Byte
1 pointer
1 XTHL None Exchange H and L with top of 1 Byte
2 stack
1 PUSH Rp Push the register pair onto the 1 Byte
3 stack
1 POP Rp Pop off stack to the register pair 1 Byte
4
1 OUT 8-bit port Output from Accumulator to 8-bit 2 Byte
5 port address
address
1 IN 8-bit port Input data to accumulator from a 2 Byte
6 port with 8-bit address
address
GTU Exam Questions
Sr. Questions Marks Year
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
1. Explain the PUSH and POP instructions of the 8085 microprocessor with 4 W’17
example.
2. Explain the following instructions of the 8085 microprocessor with suitable 7 W’17
example:
STA, LDAX, XTHL
3. Explain 8085 data transfer instructions with suitable examples. 7 S’18
4. Define opcode and operand, and specify the opcode and the operand in the 3 W’18
instruction MOV H, L
5. Explain the following instructions of the 8085 microprocessor with 4 S’19
suitable example: LHLD, SPHL, LDAX, XTHL
6. The memory location 2070H holds the data byte F2H.Write instructions to 4 W’19
transfer the data byte to the accumulator using three different opcodes: MOV,
LDAX, and LDA.
7. Register D contains 72H.Illustrate the instructions MOV and STAX to copy the 4 W’19
contents of register B into memory location 8020H using indirect addressing.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 62


Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Arithmetic Instructions
1 ADD R/M Add register or memory, to the 1 Byte
accumulator
2 ADC R/M Add register to the accumulator with 1 Byte
carry Positive Vibes:MPI is the interesting, easiest and scoring
3 ADI 8-bit Add the immediate to the accumulator
subject. 2 Byte

Arithmetic Instructions
4 data
ACI 8-bit Add the immediate to the accumulator 2 Byte
data with carry
5 DAD R p
Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from 1 Byte
accumulator
7 SBB R/M Subtract the source and borrow from 1 Byte
accumulator
8 SUI 8-bit Subtract the immediate from the 2 Byte
data accumulator
9 SBI 8-bit Subtract immediate from accumulator 2 Byte
1 data with borrow
INR R/M Increment the register or the memory by 1 Byte
0 1
1 INX Rp Increment register pair by 1 1 Byte
1
1 DCR R/M Decrement the register or the memory by 1 Byte
2 1
1 DCX Rp Decrement register pair by 1 1 Byte
3
1 DAA Decimal adjust accumulator 1 Byte
4

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 65


ADD: Add register/memory to accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
ADD R/M • The contents of the operand ADD B; A = A + B
(register or memory) are ADD M; A = A +
added to the contents of the M[HL]
accumulator and the result is
stored in the accumulator.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.
• All flags are modified to
reflect the result of the
addition.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 66


ADC: Add register to accumulator with carry
Positive Vibes:MPI is the interesting, easiest and scoring

Instruction Description Example


subject.

Opcod Operan
e d
ADC R/M • The contents of the operand ADC B; A = A + B
(register or memory) and the + CY
ADC M; A = A +
Carry flag are added to the
M[HL]+CY
contents of the accumulator
and the result is stored in the
accumulator.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.
• All flags are modified to
reflect the result of the
addition.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 67


ADI: Add immediate 8-bit with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
eADI d8-bit • The 8-bit data (operand) is ADI 03; A=A+
data added to the contents of the 03h
accumulator and the result is
stored in the accumulator.
• All flags are modified to
reflect the result of the
addition.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 68


ACI: Add immediate 8-bit to accumulator with
carry
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
ACI 8-bit • The 8-bit data (operand) and ACI 03; A=A+
data the Carry flag are added to 03h + CY
the contents of the
accumulator and the result is
stored in the accumulator.
• All flags are modified to
reflect the result of the
addition.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 69


DAD: Add register pair to H and L registers
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d DAD B
DAD Rp • The 16-bit contents of the
specified register pair are
added to the contents of the
HL register and the sum is
stored in the HL register.
• The contents of the source
register pair are not altered.
• If the result is larger than 16
bits, the CY flag is set. No
other flags are affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 70


DAD Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
Register subject.

A
B 02 08 C
D E +
H 02
04 0B
03 L 02 03

04 0B

DAD B

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 71


SUB: Subtract register/memory from
accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Instruction Description Example
Opcod Operan
e d
SUB R/M • The contents of the operand SUB B ; A=A-B
(register or memory) is SUB M ; A=A-M[HL]
subtracted from the contents
of the accumulator, and the
result is stored in the
accumulator.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.
• All flags are modified to
reflect the result of the
subtraction.
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 72
SBB: Subtract source & borrow from
accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d SBB B; A=A -
SBB R/M • The contents of the operand
(register or memory) and the (B+CY)
Borrow flag are subtracted SBB M; A=A-(M[HL]
+CY)
from the contents of the
accumulator and the result is
placed in the accumulator.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.
• All flags are modified to
reflect the result of the
Prof. Swati R Sharma
subtraction.
Unit 4 – Assembly Language Basics 73
SUI: Subtract immediate 8-bit from accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d SUI 08h; A = A -
SUI 8-bit • The 8-bit data (operand) is
data subtracted from the contents 08h
of the accumulator and the
result is stored in the
accumulator.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 74


SBI: Subtract immediate from accumulator with
borrow
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
SBI 8-bit • The 8-bit data (operand) and SBI 08h; A=A -
data the borrow (CY) are (08h+CY)
subtracted from the contents
of the accumulator and the
result is stored in the
accumulator.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 75


INR: Increment register/memory by 1
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d INR B;B=B+01
INR R/M • The contents of the
designated register or INR
memory is incremented by 1 M;M[HL]=M[HL]
+01
and the result is stored at the
same place.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 76


INX: Increment register pair by 1
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d INX D;
INX Rp The contents of the designated
register pair is incremented by 1 DE=DE+0001
and the result is stored at the
same place.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 77


DCR: Decrement register/ memory by 1
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d
DCR R/M • The contents of the DCR B;B=B-01
designated register or DCR
memory is decremented by 1 M;M[HL]=M[HL]-01
and the result is stored in the
same place.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 78


DCX: Decrement register pair by 1
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d DCX B; BC=BC-
DCX Rp The contents of the designated
register pair is decremented by 0001
1 and their result is stored at the DCX D; DE=DE-
0001
same place.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 79


DAA: Decimal Adjust Accumulator
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Opcod Operan
e d DAA
DAA None • The contents of the
accumulator is changed from
a binary value to two 4-bit
BCD digits.
• 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.
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 80
DAA Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Register
s 1 11
A 2 001 1010
A 0
B C +0000 01
10
D E 0 01 1 0000
H L
Valid BCD
number

3
0

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 81


1 ADD R/M Add register or memory, to the 1 Byte
accumulator
2 ADC R/M Add register to the accumulator with 1 Byte
carry
3 ADI 8-bit Add the immediate to the accumulator 2 Byte
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Arithmetic Instructions
4 data
ACI 8-bit Add the immediate to the accumulator 2 Byte
data with carry
5 DAD R p
Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from 1 Byte
accumulator
7 SBB R/M Subtract the source and borrow from 1 Byte
accumulator
8 SUI 8-bit Subtract the immediate from the 2 Byte
data accumulator
9 SBI 8-bit Subtract immediate from accumulator 2 Byte
1 data with borrow
INR R/M Increment the register or the memory by 1 Byte
0 1
1 INX Rp Increment register pair by 1 1 Byte
1
1 DCR R/M Decrement the register or the memory by 1 Byte
2 1
1 DCX Rp Decrement register pair by 1 1 Byte
3
1 DAA Decimal adjust accumulator 1 Byte
4

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 82


Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Branch Instructions
1 JMP Jump unconditionally 3 Byte
2 JC Jump on carry 3 Byte
3 JNC Jump on no carry 3 Byte
4 JP Jump on positive 3 Byte
5 JM Jump on minus 3 Byte Positive Vibes:MPI is the interesting, easiest and scoring
subject.
6 JZ Jump on zero 3 Byte
7 JNZ Jump on no zero 3 Byte
8 JPE Jump on parity even 3 Byte
9 JPO Jump on parity odd 3 Byte
1 CALL Call unconditionally 3 Byte
Branch Instructions

0
1 CC Call on carry 3 Byte
1
1 CNC Call on no carry 3 Byte
2
1 CP Call on positive 3 Byte
3
1 CM Call on minus 3 Byte
4
1 CZ Call on zero 3 Byte
5
1 CNZ Call on no zero 3 Byte
6
1 CPE Call on parity even 3 Byte
7
1 CPO Call on parity odd 3 Byte
8
1 RET Return unconditionally 1 Byte
9
JMP: Jump unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d JMP 000AH
JMP 16-bit The program sequence is
transferred to the memory
address address given in the operand.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 86


JMP: Jump unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Memo Instructi Memo Instructi


ry ons ry ons
Addre Label
ss MVI A,05
0000H MVI A,05 MOV B,A
0002H MOV B,A MOV C,B
0003H MOV C,B JMP L1
0004H JMP 0009 ADI 02
0007H ADI 02 L1: SUB B
0009H SUB B HLT
000AH HLT

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 87


Branch Instruction
Jump Conditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Instruction Description Example
Opco Operand
de
JC 16-bit Jump on Carry, Flag Status: JC 2030H
address
JNC 16-bit CY=1
Jump on No Carry, Flag JNC 2030H
address
JZ 16-bit Status:
Jump on CY=0
Zero, Flag Status: JZ 2030H
address
JNZ 16-bit Z=1
Jump on No Zero, Flag JNZ 2030H
address
JP 16-bit Status:
Jump Z=0on Positive, Flag JP 2030H
address
JM 16-bit Status:
Jump onS=0
Minus, Flag Status: JM 2030H
address
JPE 16-bit S=1
Jump on Parity Even, JPE 2030H
address Flag Status: P=1
JPO 16-bit Jump on Parity Odd, JPO 2030H
address Flag Status: P=0

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 88


RET: Return from subroutine unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d The program sequence is transferred RET
RET
from the subroutine to the calling
program.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 89


CALL: Call Unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d CALL 000AH
CALL 16-bit Instruction transfers the
program sequence to the
address memory address given in the
operand. Before transferring,
the address of the next
instruction(PC) is pushed onto
the stack.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 90


CALL: Call Unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
Lin Instruction Address PC SP
subject. 05 [2008
]
e
1 LXI H,1002 [0000] [0003] 0
SP [2007
2 LXI D,3002 [0003] [0006] 0
09 ]
SP
[2006
3 CALL ADD1 [0006] [0009]
0009 ]
4 LXI B,4002 [0009] [000C] [2005
]
5 ADD1:MOV A,D [000C] [000D]
6 ADD H [000D] [000E]
7 RET [000E]

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 91


Branch Instruction
CALL Conditionally
Positive Vibes:MPI is the interesting, easiest and scoring

Instruction Description Example


subject.

Opco Operand
de
CC 16-bit Call on Carry, Flag Status: CC 2030H
address
CNC 16-bit CY=1
Call on No Carry, Flag Status: CNC 2030H
address
CZ 16-bit CY=0
Call on Zero, Flag Status: CZ 2030H
address
CNZ 16-bit Z=1
Call on No Zero, Flag Status: CNZ 2030H
address
CP 16-bit Z=0
Call on Positive, Flag Status: CP 2030H
address
CM 16-bit S=0
Call on Minus, Flag Status: CM 2030H
address
CPE 16-bit S=1
Call on Parity Even, CPE 2030H
address Flag Status: P=1
CPO 16-bit Call on Parity Odd, CPO 2030H
address Flag Status: P=0

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 92


Branch Instruction
Return from Subroutine
Positive Vibes:MPI is the interesting, easiest and scoring

Instruction Description subject.


Example
Opcod Operand
e
RC 16-bit Return on Carry, CY=1 RC
address
RNC 16-bit Return on No Carry, CY=0 RNC
address
RZ 16-bit Return on Zero, Z=1 RZ
address
RNZ 16-bit Return on No Zero, Z=0 RNZ
address
RP 16-bit Return on Positive, S=0 RP
address
RM 16-bit Return on Minus, S=1 RP
address
RPE 16-bit Return on Parity Even, RPE
address Flag Status: P=1
RPO 16-bit Return on Parity Odd, RPO
address Flag Status: P=0

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 93


PCHL: Load program counter with HL contents
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d PCHL
PCHL None • The contents of registers H &
L are copied into the program
counter.
• The contents of H are placed
as the high-order byte and
the contents of L as the low-
order byte.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 94


RST: Restart
Positive Vibes:MPI is the interesting, easiest and scoring

Instruction Description Exampl


subject.

Opcod Operan e
e d RST 5
RST 0- The RST instruction is used as software
7(N) instructions in a program to transfer the
program execution to one of the
following eight locations.
Instruction Restart Address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 95


Branch Instruction
The 8085 has additionally 4 interrupts, which can generate RSTPositive Vibes:MPI is the interesting, easiest and scoring
subject.
instructions internally and doesn’t require any external hardware.

Instruction Description Example


Opcod Operan
e d
TRAP None It restart from address 0024H TRAP
RST 5.5 It restart from address 002CH RST 5.5
RST None
6.5 It restart from address 0034H RST 6.5
RST None
7.5 It restart from address 003CH RST 7.5
None

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 96


1 JMP Jump unconditionally 3 Byte
2 JC Jump on carry 3 Byte
3 JNC Jump on no carry 3 Byte
4 JP Jump on positive 3 Byte
5 JM Jump on minus 3 Byte Positive Vibes:MPI is the interesting, easiest and scoring
subject.
6 JZ Jump on zero 3 Byte
7 JNZ Jump on no zero 3 Byte
8 JPE Jump on parity even 3 Byte
9 JPO Jump on parity odd 3 Byte
1
Branch Instructions
CALL Call unconditionally 3 Byte
0
1
CC Call on carry 3 Byte
1
1
CNC Call on no carry 3 Byte
2
1
CP Call on positive 3 Byte
3
1
CM Call on minus 3 Byte
4
1
CZ Call on zero 3 Byte
5
1
CNZ Call on no zero 3 Byte
6
1
CPE Call on parity even 3 Byte
7
1
CPO Call on parity odd 3 Byte
8
1
RET Return unconditionally 1 Byte
9
Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Logical & Bit


Manipulation
Instructions
1 CMP Compare register or memory with accumulator 1 Byte

Logical & Bit Manipulation Instructions


2 CPI Compare immediate with accumulator 2 Byte
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Logical AND register or memory with


3 ANA 1 Byte
accumulator
4 ANI Logical AND immediate with accumulator 2 Byte
Exclusive OR register or memory with
5 XRA 1 Byte
accumulator
6 XRI Exclusive OR immediate with accumulator 2 Byte
Logical OR register or memory with
7 ORA 1 Byte
accumulator
8 ORI Logical OR immediate with accumulator 2 Byte
9 RLC Rotate accumulator left 1 Byte
1
RRC Rotate accumulator right 1 Byte
0
1
RAL Rotate accumulator left through carry 1 Byte
1
1
RAR Rotate accumulator right through carry 1 Byte
2
1
Prof. Swati R Sharma CMA ComplementUnit
accumulator
4 – Assembly Language Basics 1 Byte 100
CMP: Compare register/memory with
accumulator
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Opcod Operan
e d CMP B
CMP R/M The contents of the operand
(register or memory) is CMP M
compared with the contents of
the accumulator. Both contents
are preserved. The result of the
comparison is shown by setting
the flags:
1. if (A) < (reg/mem): carry flag
is set(1).
2. if (A) = (reg/mem): zero flag
is set(1).
3. if (A) > (reg/mem): carry and
zero flags are reset(0).

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 101


CPI: Compare immediate with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring

Instruction Description Example


subject.

Opcod Operan
e d CPI 89H
CPI 8-bit • The second byte data is
data compared with the contents
of the accumulator.
• The values being compared
remain unchanged. The result
of the comparison is shown
by setting the flags:
1. if (A) < data: carry flag is
set(1).
2. if (A) = data: zero flag is
set(1).
3. if (A) > data: carry and zero
flags are reset(0).

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 102


ANA: AND register/memory with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
Instruction Description subject. Example
Opcod Operan
e d ANA B
ANA R/M • The contents of the accumulator
are logically ANDed with the ANA M
contents of the operand (register
or memory), and the result is
placed in the accumulator.
• If the operand is a memory
location, its address is specified
by the contents of HL registers.
• S, Z, P are modified to reflect the
result of the operation.
• CY is reset. AC is set.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 103


ANI: AND immediate with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d ANI 02H
ANI 8-bit • The contents of the accumulator
data are logically ANDed with the 8-bit
data (operand) and the result is
placed in the accumulator.
• S, Z, P are modified to reflect the
result of the operation.
• CY is reset. AC is set.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 104


ORA: OR register/memory with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d ORA B
ORA R/M • The contents of the accumulator
is logically ORed with the ORA M
contents of the operand (register
or memory), and the result is
placed in the accumulator.
• If the operand is a memory
location, its address is specified
by the contents of HL registers.
• S, Z, P are modified to reflect the
result of the operation. CY and AC
are reset.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 105


ORI: OR immediate with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d ORI 02H
ORI 8-bit • The contents of the accumulator
data is logically ORed with the 8-bit
data (operand) and the result is
placed in the accumulator.
• S, Z, P are modified to reflect the
result of the operation.
• CY is reset. AC is set.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 106


XRA: Exclusive OR register/memory with
accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d XRA B
XRA R/M • The contents of the accumulator
is Exclusive ORed with the XRA M
contents of the operand (register
or memory), and the result is
placed in the accumulator.
• If the operand is a memory
location, its address is specified
by the contents of HL registers.
• S, Z, P are modified to reflect the
result of the operation. CY and AC
are reset.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 107


XRI: Exclusive OR immediate with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d XRI 02H
XRI 8-bit • The contents of the accumulator
data are Exclusive Ored with the 8-bit
data (operand) and the result is
placed in the accumulator.
• S, Z, P are modified to reflect the
result of the operation.
• CY is reset. AC is set.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 108


RLC: Rotate accumulator left
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d RLC
RLC None • 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).
• CY is modified according to bit D7.
• S, Z, P, AC are not affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 109


Logical Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
RLC

A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 0
0 1 0 1 0 0 0 1

Rotate the accumulator left CY

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 110


RRC: Rotate accumulator right
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d RRC
RRC None • 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).
• CY is modified according to bit D0.
• S, Z, P, AC are not affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 111


RRC: Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 0
1 0 1 0 1 0 0

Rotate the accumulator right

CY

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 112


RAL: Rotate accumulator left through carry
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d RAL
RAL None • Each binary bit of the
accumulator is rotated left by one
position through the Carry flag.
• 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.
• S, Z, P, AC are not affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 113


RAL: Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 0
0 1 0 1 0 0 0

CY
0
Rotate the accumulator left through carry

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 114


RAR: Rotate accumulator right through carry
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d RAR
RAR None • Each binary bit of the
accumulator is rotated right by
one position through the Carry
flag.
• 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.
• S, Z, P, AC are not affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 115


RAR: Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 0
1 0 1 0 1 0 0

Rotate the accumulator right through carry

CY
1

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 116


CMA: Complement accumulator
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d CMA
CMA None The contents of the accumulator are
complemented. No flags are
affected.

A 2A CMA

001 1010
0
1100101
1
D 5

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 117


Logical Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
CMC: Complement Carry subject.

Instruction Description Example


Opcod Operan
e d CMC
CMC None The Carry flag is complemented. No
other flags are affected.

STC: Set Carry


Instruction Description Example
Opcod Operan
e
STC d
None The Carry flag is set(1). No other STC
flags are affected.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 118


1 CMP Compare register or memory with accumulator 1 Byte

Logical & Bit Manipulation Instructions


2 CPI Compare immediate with accumulator 2 Byte
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Logical AND register or memory with


3 ANA 1 Byte
accumulator
4 ANI Logical AND immediate with accumulator 2 Byte
Exclusive OR register or memory with
5 XRA 1 Byte
accumulator
6 XRI Exclusive OR immediate with accumulator 2 Byte
Logical OR register or memory with
7 ORA 1 Byte
accumulator
8 ORI Logical OR immediate with accumulator 2 Byte
9 RLC Rotate accumulator left 1 Byte
1
RRC Rotate accumulator right 1 Byte
0
1
RAL Rotate accumulator left through carry 1 Byte
1
1
RAR Rotate accumulator right through carry 1 Byte
2
1
Prof. Swati R Sharma CMA ComplementUnit
accumulator
4 – Assembly Language Basics 1 Byte 119
Classification of 8085 Instructions

Positive Vibes:MPI is the interesting, easiest and scoring


subject.

Based on Byte Size Based on Function


One-byte Instructions Data Transfer Instructions
Requires one memory location
to perform an operation
Arithmetic Instructions
E.g. CMA, ADD

Two-byte Instructions Logic & Bit Manipulation


Requires two memory locations Instructions
to perform an operation Branch Instructions
E.g. MVI A,32H

Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Control Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Control Instructions
1 NOP No operation 1 Byte
2 HLT Halt 1 Byte
3 DI Disable interrupts 1 Byte
4 EI Enable interrupts 1 Byte
5 RIM Read interrupt mask 1 Byte
6 SIM Set interrupt mask 1 Byte

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 122


Control Instructions
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Opcod Operan
e d NOP
NOP None • No operation is performed. The
instruction is fetched and
decoded. However no operation is
executed.
• It is used to increase processing
time of execution.
• 1 CPU cycle is "wasted" to
HLT None execute
The CPU afinishes
NOP instruction.
executing the HLT
current instruction and stops further
execution. An interrupt or reset is
necessary to exit from the halt state.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 123


Control Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
Instruction Description subject. Example
Opcod Operan
e d DI
DI None Disable Interrupt
The interrupt enable flip-flop is reset
and all the interrupts except the
TRAP are disabled. No flags are
EI None affected.
Enable Interrupt EI
• The interrupt enable flip-flop is
set and all interrupts are enabled.
• No flags are affected.
• This instruction is necessary to re
enable the interrupts (except
TRAP).

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 124


SIM: Set Interrupt Mask
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Instruction Description Example


Opcod Operan
e d SIM
SIM None This is a multipurpose instruction
used to :
1. Set the status of interrupts 7.5,
6.5, 5.5
2. Set serial data input bit.
The instruction loads eight bits in
the accumulator with the following
interpretations.

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 125


SIM Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
A:Accumulator subject.

D7 D6 D5 D4 D3 D2 D1 D0
SOD SDE X R7.5 MS M7. M6.
E 5 5 M5.
Serial Output Reset 5
Data To set mask for RST7.5,RST
RST 7.5 if
It is used to 6.5, RST5.5
D4=1
transmit o/p Interrupt Masked if bit=1
bits. Serial Data
Ignored if D6=0 Enable
If D6=1; bit D7 is
output to SOD Mask Set Enable: if 0, bits 0-2
Latch are ignored
if 1, mask is set

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 126


SIM Instruction
Positive Vibes:MPI is the interesting, easiest and scoring
subject.

D7 D6 D5 D4 D3 D2 D1 D0
Accumul SOD SDE X R7.5 MS M7. M6. M5.
ator E 5 5 5
Example 1: MVI A,08H
SIM
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 0 0 0

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 127


RIM: Read Interrupt Mask
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Opcod Operan
e d RIM
RIM None
This is a multipurpose instruction
used to
1. Read the status of interrupts 7.5,
6.5, 5.5
2. Read serial data input bit.
A:AccumulatorIt reads eight bits from accumulator
D7 withD6 following
D5 Dinterpretations.
4 D3 D2 D1 D0
SID I7 I6 I5 IE 7. 6. 5.
5 5 5
To To identify pending To read interrupt
receive interrupts mask
serial 1=pending interrupt Interrupt Masked if
data Interrupt Enable
0=no pending interrupt Flag: 1=enable;
bit=1
0=disable

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 128


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Control Instructions
1 NOP No operation 1 Byte
2 HLT Halt 1 Byte
3 DI Disable interrupts 1 Byte
4 EI Enable interrupts 1 Byte
5 RIM Read interrupt mask 1 Byte
6 SIM Set interrupt mask 1 Byte

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 129


GTU Exam Questions
Sr Questions Mar Yea
Positive Vibes:MPI is the interesting, easiest and scoring
. ks rsubject.
1. Explain the SIM and RIM instructions of the 8085 3 S’19
microprocessor.
2. Explain the Functions of following instructions: 3 W’1
i. RAL 9
ii. LDAX
iii. ADC
3. Explain the Functions of following instructions: 3 W’1
i. RLC 9
ii. LHLD
iii. SBB

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 130


References
Book: Microprocessor Architecture, Programming, and Applications
Positive Vibes:MPI is thewith
interesting, easiest and scoring

the 8085, Ramesh S. Gaonkar Pub: Penram International


subject.

Mobile 8085 and 8086 Microprocessor Opcodes app from Play Store:
Applicatio http://tiny.cc/aopcodes
n

Prof. Swati R Sharma Unit 4 – Assembly Language Basics 131


Positive Vibes:MPI is the interesting, easiest and scoring
subject.

Thank You

You might also like