0% found this document useful (0 votes)
2 views

Unit-4 - Assembly Language Programming Basics (Part-1)

The document provides an overview of Assembly Language Programming Basics, focusing on the 8085 instruction set and its classification. It discusses the hierarchy of programming languages, the role of compilers and assemblers, and the structure of assembly language instructions. Additionally, it highlights the advantages of high-level languages and the importance of learning assembly language for system-level programming.

Uploaded by

jay2001p
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)
2 views

Unit-4 - Assembly Language Programming Basics (Part-1)

The document provides an overview of Assembly Language Programming Basics, focusing on the 8085 instruction set and its classification. It discusses the hierarchy of programming languages, the role of compilers and assemblers, and the structure of assembly language instructions. Additionally, it highlights the advantages of high-level languages and the importance of learning assembly language for system-level programming.

Uploaded by

jay2001p
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
You are on page 1/ 132

Microprocessor and Interfacing

(MPI)
GTU # 3160712

Unit-4:
Assembly Language
Programming Basics
PART-I: 8085 Instruction Set
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Subject Overview
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. No. Unit % Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 12%
4 Assembly Language Programming Basics 13%
5 8085 Assembly Language Programs 12%
6 Stack & Subroutines 13%
7 I/O Interfacing 20%
8 Advanced Microprocessors 15%

Unit 4 – Assembly Language Basics 2


 Topics
Loopingto be covered
Positive Vibes:MPI is the interesting, easiest and scoring subject.

▪ Assembly Language Programming 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 Program Positive Vibes:MPI is the interesting, easiest and scoring subject.

Machine Independent
High Level Language High Level Language
Machine Specific Low Level Language
Assembly Language
• Assembly language
is a low-level
MOV BL,05h1100 1011 Machine Language programming
ADD CL 1100 1110 Native to adesigned
• language
MUL BH 0100 1111
forprocessor:
a specific type of
executed directly
processor.
Micro Program Control
by hardware
• Uses symbolic
Instructions
• names to represent
Hardware consist of registers
operations, binary
code: 1s and
and 0s
memory
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 Language Positive Vibes:MPI is the interesting, easiest and scoring subject.

Compiler

Compiler Assembly Language

Assembler

Machine Language

Compilers translate high-levelAssemblers


programs to machine assembly
translates code code to machine code
either directly, or Indirectly via an assembler

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 computer, what to do?).
Positive Vibes:MPI is the interesting, easiest and scoring subject.

 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).

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.

Unit 4 – Assembly Language Basics 10


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

Opcode Operand
MOV Rd, Rs
M, Rs
R, M

Rd → Destination Register
Rs → Source Register
M → Memory

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 Language:


MVI A,02 1001 1011 0010
MVI B,03 1001 1001 0011
ADD B
1011 0011 0010

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.

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

Unit 4 – Assembly Language Basics 16


Why to Learn Assembly Language?
 Writing assembly programs gives the computer designer, deep understanding of the instruction
Positive Vibes:MPI is the interesting, easiest and scoring subject.

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.

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

Unit 4 – Assembly Language Basics 19


Assembler
 An assembler is a program that converts programs written in assembly language into object
Positive Vibes:MPI is the interesting, easiest and scoring subject.

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.

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.

Unit 4 – Assembly Language Basics 21


Assembly Language Programming Tools
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Assemble 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

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.

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.

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 perform a specific
Positive Vibes:MPI is the interesting, easiest and scoring subject.

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.

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

Opcode Operand

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, L)


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

Unit 4 – Assembly Language Basics 29


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

Instruction Binary Code Hexa Code


Opcode Operand
MOV C,A 0100 1111 4FH
ADD B 1000 0000 80H
CMA 0010 1111 2FH

Unit 4 – Assembly Language Basics 30


List of one-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. Instruction Sr. Instruction Sr. Instruction Sr. Instruction
1 MOV dest.,src 13 SBB R/M 25 RNZ 37 CMA
2 LDAX RP (B/D) 14 INR R/M 26 RPE 38 CMC
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

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

Unit 4 – Assembly Language Basics 32


List of two-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. Instruction
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

Unit 4 – Assembly Language Basics 33


Three-byte Instruction
Positive Vibes:MPI is the interesting, easiest and scoring subject.
In three-byte instruction,
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

Unit 4 – Assembly Language Basics 34


List of three-byte Instructions
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. Instruction Sr. Instruction
1 LDA 16-bit address 13 JPE 16-bit address
2 LXI Rp, 16-bit data 14 JPO 16-bit address
3 LHLD 16-bit address 15 CALL 16-bit address
4 STA 16-bit address 16 CC 16-bit address
5 SHLD 16-bit address 17 CNC 16-bit address
6 JMP 16-bit address 18 CP 16-bit address
7 JC 16-bit address 19 CM 16-bit address
8 JNC 16-bit address 20 CZ 16-bit address
9 JP 16-bit address 21 CNZ 16-bit address
10 JM 16-bit address 22 CPE 16-bit address
11 JZ 16-bit address 23 CPO 16-bit address
12 JNZ 16-bit address

Unit 4 – Assembly Language Basics 35


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

Sr Questions Marks Year


1. Explain the functions of following instructions of 8085 – state the bytes occupied, number of Machine 4 W’18
cycle required and T-States
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’19
number of bytes occupied, number of Machine cycle required and T-states.
1. MOV A,M
2. LXI H,1000H
3. DAA
3. Explain One byte, Two byte, Three byte instruction. 4 W’19

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.

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


Opcode Operand
MOV Rd, Rs • This instruction copies the contents MOV B, C ; BC
MOV M, R of the source register into the MOV B, M;BM[HL]
MOV R, M destination 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.

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


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

Unit 4 – Assembly Language Basics 41


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

LDA 2050H

Registers Memory
02 2000
A
04 …
B C 0A ..
06 .
D E
0F 2049
H L 0D 2050
05 2051
03 2052

Unit 4 – Assembly Language Basics 42


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

Instruction Description Example


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

Unit 4 – Assembly Language Basics 43


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

Instruction Description Example


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

Unit 4 – Assembly Language Basics 44


Example: LDAX Instruction
LDAX B ; AM[BC]
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Registers Memory
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

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


Opcode Operand
LXI Rp, 16-bit The instruction loads immediate LXI H, 2034H
Data 16-bit data into register pair.

Registers

A
B
D
H 20 34 L

Unit 4 – Assembly Language Basics 46


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

Instruction Description Example


Opcode Operand
STA 16-bit The contents of accumulator is copied STA 0002H
address into the memory location specified by the 16-bit memory address
operand.

Unit 4 – Assembly Language Basics 47


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

Instruction Description Example


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

Registers Memory
02 0001
A
04 0002
B C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008

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


Opcode Operand
LHLD 16-bit • The instruction copies contents of the LHLD 2050H
address memory location pointed out by the LHLD 0006H
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.

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


Opcode Operand
SHLD 16-bit The contents of register L is stored in SHLD 0002H
address memory location specified by the 16-bit
address in the operand and the contents
of H register is stored into the next
memory location by incrementing the
operand.

Memory
0001
0002
H A2 D3 L 0003
0004

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


Opcode Operand
XCHG None The contents of register H are exchanged XCHG
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

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


Opcode Operand
SPHL None The instruction loads the contents of the SPHL
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 (16)
H A2 D3 L

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


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

Registers Memory
0001
3F 0002 SP
H A2 D3 L 0003
2C SP
0004

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

Registers Memory

A SP 23 0008
SP 06 0007
B 06 40 C SP 40 0006
D E 0005
0004
H L 0003
0002
0001

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.

Opcode Operand

PUSH Rp The contents of the register pair PUSH B


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.

Unit 4 – Assembly Language Basics 56


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

Registers Memory
SP 03 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

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 location POP B


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.

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


Opcode Operand
OUT 8-bit The contents of the accumulator are OUT 0AH
port copied into the I/O port specified by the
address operand.

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


Opcode Operand
IN 8-bit The contents of the input port designated IN 0AH
port in the operand are read and loaded into
address the accumulator.

Unit 4 – Assembly Language Basics 60


1 MOV Dst,Src Copy content 1 Byte
2 MVI (R/M), 8-bit Data Load 8-bit to Register/Memory 2 Byte
3 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
6 STA 16-bit address Store Accumulator 3 Byte
Data Transfer Instructions

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
10 XCHG None Exchange H and L with D and E 1 Byte
11 SPHL None Copy H and L registers to the stack pointer 1 Byte
12 XTHL None Exchange H and L with top of stack 1 Byte
13 PUSH Rp Push the register pair onto the stack 1 Byte
14 POP Rp Pop off stack to the register pair 1 Byte
15 OUT 8-bit port address Output from Accumulator to 8-bit port 2 Byte
address
16 IN 8-bit port address Input data to accumulator from a port with 2 Byte
8-bit address
GTU Exam Questions
Sr. Questions Marks
Positive Vibes:MPI is the interesting, easiest and scoring subject. Year
1. Explain the PUSH and POP instructions of the 8085 microprocessor with example. 4 W’17
2. Explain the following instructions of the 8085 microprocessor with suitable example: 7 W’17
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 instruction MOV H, L 3 W’18
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 transfer the data byte to the 4 W’19
accumulator using three different opcodes: MOV, LDAX, and LDA.
7. Register D contains 72H.Illustrate the instructions MOV and STAX to copy the contents of register B 4 W’19
into memory location 8020H using indirect addressing.

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 accumulator 1 Byte
2 ADC R/M Add register to the accumulator with carry 1 Byte
Positive Vibes:MPI is the interesting, easiest and scoring subject.
3 ADI 8-bit data Add the immediate to the accumulator 2 Byte
4 ACI 8-bit data Add the immediate to the accumulator with carry 2 Byte
Arithmetic Instructions
5 DAD Rp Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from accumulator 1 Byte
7 SBB R/M Subtract the source and borrow from accumulator 1 Byte
8 SUI 8-bit data Subtract the immediate from the accumulator 2 Byte
9 SBI 8-bit data Subtract immediate from accumulator with borrow 2 Byte
10 INR R/M Increment the register or the memory by 1 1 Byte
11 INX Rp Increment register pair by 1 1 Byte
12 DCR R/M Decrement the register or the memory by 1 1 Byte
13 DCX Rp Decrement register pair by 1 1 Byte
14 DAA Decimal adjust accumulator 1 Byte

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


Opcode Operand
ADD R/M • The contents of the operand (register ADD B; A = A + B
or memory) are added to the contents ADD M; A = A + M[HL]
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.

Unit 4 – Assembly Language Basics 66


ADC: Add register to accumulator with carry
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Instruction Description Example
Opcode Operand
ADC R/M • The contents of the operand (register ADC B; A = A + B + CY
or memory) and the Carry flag are ADC M; A = A + M[HL]+CY
added to 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 addition.

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


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

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


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

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


Opcode Operand
DAD Rp • The 16-bit contents of the specified DAD B
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.

Unit 4 – Assembly Language Basics 70


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

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

04 0B
DAD B

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


Opcode Operand
SUB R/M • The contents of the operand (register SUB B ; A=A-B
or memory) is subtracted from the SUB M ; A=A-M[HL]
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.

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


Opcode Operand
SBB R/M • The contents of the operand (register SBB B; A=A - (B+CY)
or memory) and the Borrow flag are SBB M; A=A-(M[HL]+CY)
subtracted 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 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


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

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


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

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


Opcode Operand
INR R/M • The contents of the designated INR B;B=B+01
register or memory is incremented by INR M;M[HL]=M[HL]+01
1 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.

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


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

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


Opcode Operand
DCR R/M • The contents of the designated DCR B;B=B-01
register or memory is decremented by DCR M;M[HL]=M[HL]-01
1 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.

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


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

Unit 4 – Assembly Language Basics 79


DAA: Decimal Adjust Accumulator
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Opcode Operand
DAA None • The contents of the accumulator is DAA
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.

Unit 4 – Assembly Language Basics 80


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

Registers
1 11
A 2A 0010 1010
B C +0000 0110
D E 0 01 1 0 00 0
H L
Valid BCD number

30

Unit 4 – Assembly Language Basics 81


1 ADD R/M Add register or memory, to the accumulator 1 Byte
2 ADC R/M Add register to the accumulator with carry 1 Byte
3 ADI 8-bit data Add the immediate to the accumulator Positive Vibes:MPI is the interesting, easiest and scoring subject.
2 Byte
4 ACI 8-bit data Add the immediate to the accumulator with carry 2 Byte
Arithmetic Instructions
5 DAD Rp Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from accumulator 1 Byte
7 SBB R/M Subtract the source and borrow from accumulator 1 Byte
8 SUI 8-bit data Subtract the immediate from the accumulator 2 Byte
9 SBI 8-bit data Subtract immediate from accumulator with borrow 2 Byte
10 INR R/M Increment the register or the memory by 1 1 Byte
11 INX Rp Increment register pair by 1 1 Byte
12 DCR R/M Decrement the register or the memory by 1 1 Byte
13 DCX Rp Decrement register pair by 1 1 Byte
14 DAA Decimal adjust accumulator 1 Byte

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
10 CALL Call unconditionally 3 Byte
11 CC Call on carry 3 Byte
Branch Instructions

12 CNC Call on no carry 3 Byte


13 CP Call on positive 3 Byte
14 CM Call on minus 3 Byte
15 CZ Call on zero 3 Byte
16 CNZ Call on no zero 3 Byte
17 CPE Call on parity even 3 Byte
18 CPO Call on parity odd 3 Byte
19 RET Return unconditionally 1 Byte
20 RC Return on carry 1 Byte
21 RNC Return on no carry 1 Byte
22 RP Return on positive 1 Byte
23 RM Return on minus 1 Byte
24 RZ Return on zero 1 Byte
25 RNZ Return on no zero 1 Byte
26 RPE Return on parity even 1 Byte
27 RPO Return on parity odd 1 Byte
28 PCHL Load program counter with HL contents 1 Byte
29 RST Restart 1 Byte
JMP: Jump unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Instruction Description Example


Opcode Operand
JMP 16-bit The program sequence is transferred to JMP 000AH
address the memory address given in the
operand.

Unit 4 – Assembly Language Basics 86


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

Memory Instructions Memory Instructions


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

Unit 4 – Assembly Language Basics 87


Branch Instruction
Jump Conditionally
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Instruction Description Example


Opcode Operand
JC 16-bit address Jump on Carry, Flag Status: CY=1 JC 2030H
JNC 16-bit address Jump on No Carry, Flag Status: CY=0 JNC 2030H
JZ 16-bit address Jump on Zero, Flag Status: Z=1 JZ 2030H
JNZ 16-bit address Jump on No Zero, Flag Status: Z=0 JNZ 2030H
JP 16-bit address Jump on Positive, Flag Status: S=0 JP 2030H
JM 16-bit address Jump on Minus, Flag Status: S=1 JM 2030H
JPE 16-bit address Jump on Parity Even, JPE 2030H
Flag Status: P=1
JPO 16-bit address Jump on Parity Odd, JPO 2030H
Flag Status: P=0

Unit 4 – Assembly Language Basics 88


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

Instruction Description Example


Opcode Operand
RET The program sequence is transferred RET
from the subroutine to the calling
program.

Unit 4 – Assembly Language Basics 89


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

Instruction Description Example


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

Unit 4 – Assembly Language Basics 90


CALL: Call Unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Line Instruction Address PC SP→ 05 [2008]

1 LXI H,1002 [0000] [0003] SP→ 00 [2007]

2 LXI D,3002 [0003] [0006] SP→ 09 [2006]

3 CALL ADD1 [0006] [0009]


0009 [2005]

4 LXI B,4002 [0009] [000C]


5 ADD1:MOV A,D [000C] [000D]
6 ADD H [000D] [000E]
7 RET [000E]

Unit 4 – Assembly Language Basics 91


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

Instruction Description Example


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

Unit 4 – Assembly Language Basics 92


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

Instruction Description Example


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

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


Opcode Operand
PCHL None • The contents of registers H & L are PCHL
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.

Unit 4 – Assembly Language Basics 94


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

Instruction Description Example


Opcode Operand
RST 0-7(N) The RST instruction is used as software RST 5
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

Unit 4 – Assembly Language Basics 95


Branch Instruction
The 8085 has additionally 4 interrupts, which can generate RST instructions Positive Vibes:MPI is the interesting, easiest and scoring subject.

internally and doesn’t require any external hardware.

Instruction Description Example


Opcode Operand
TRAP None It restart from address 0024H TRAP
RST 5.5 None It restart from address 002CH RST 5.5
RST 6.5 None It restart from address 0034H RST 6.5
RST 7.5 None It restart from address 003CH RST 7.5

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
10 CALL Call unconditionally 3 Byte
11 CC Call on carry 3 Byte
Branch Instructions

12 CNC Call on no carry 3 Byte


13 CP Call on positive 3 Byte
14 CM Call on minus 3 Byte
15 CZ Call on zero 3 Byte
16 CNZ Call on no zero 3 Byte
17 CPE Call on parity even 3 Byte
18 CPO Call on parity odd 3 Byte
19 RET Return unconditionally 1 Byte
20 RC Return on carry 1 Byte
21 RNC Return on no carry 1 Byte
22 RP Return on positive 1 Byte
23 RM Return on minus 1 Byte
24 RZ Return on zero 1 Byte
25 RNZ Return on no zero 1 Byte
26 RPE Return on parity even 1 Byte
27 RPO Return on parity odd 1 Byte
28 PCHL Load program counter with HL contents 1 Byte
29 RST Restart 1 Byte
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
2 CPI Compare immediate with accumulator 2 Byte
Positive Vibes:MPI is the interesting, easiest and scoring subject.

3 ANA Logical AND register or memory with accumulator 1 Byte

Logical & Bit Manipulation Instructions


4 ANI Logical AND immediate with accumulator 2 Byte
5 XRA Exclusive OR register or memory with accumulator 1 Byte
6 XRI Exclusive OR immediate with accumulator 2 Byte
7 ORA Logical OR register or memory with accumulator 1 Byte
8 ORI Logical OR immediate with accumulator 2 Byte
9 RLC Rotate accumulator left 1 Byte
10 RRC Rotate accumulator right 1 Byte
11 RAL Rotate accumulator left through carry 1 Byte
12 RAR Rotate accumulator right through carry 1 Byte
13 CMA Complement accumulator 1 Byte
14 CMC Complement carry 1 Byte
15 STC Set carry 1 Byte

Unit 4 – Assembly Language Basics 100


CMP: Compare register/memory with accumulator
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Opcode Operand
CMP R/M The contents of the operand (register or CMP B
memory) is compared with the contents CMP M
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).

Unit 4 – Assembly Language Basics 101


CPI: Compare immediate with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Instruction Description Example
Opcode Operand
CPI 8-bit • The second byte data is compared CPI 89H
data 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).

Unit 4 – Assembly Language Basics 102


ANA: AND register/memory with accumulator
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Instruction Description Example
Opcode Operand
ANA R/M • The contents of the accumulator are ANA B
logically ANDed with the contents of the ANA M
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.

Unit 4 – Assembly Language Basics 103


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

Instruction Description Example


Opcode Operand
ANI 8-bit • The contents of the accumulator are ANI 02H
data 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.

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


Opcode Operand
ORA R/M • The contents of the accumulator is ORA B
logically ORed with the contents of the ORA M
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.

Unit 4 – Assembly Language Basics 105


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

Instruction Description Example


Opcode Operand
ORI 8-bit • The contents of the accumulator is logically ORI 02H
data 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.

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


Opcode Operand
XRA R/M • The contents of the accumulator is XRA B
Exclusive ORed with the contents of the XRA M
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.

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


Opcode Operand
XRI 8-bit • The contents of the accumulator are XRI 02H
data 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.

Unit 4 – Assembly Language Basics 108


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

Instruction Description Example


Opcode Operand
RLC None • Each binary bit of the accumulator is RLC
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.

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

Unit 4 – Assembly Language Basics 110


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

Instruction Description Example


Opcode Operand
RRC None • Each binary bit of the accumulator is RRC
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.

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

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


Opcode Operand
RAL None • Each binary bit of the accumulator is RAL
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.

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

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


Opcode Operand
RAR None • Each binary bit of the accumulator is RAR
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.

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

Unit 4 – Assembly Language Basics 116


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

Instruction Description Example


Opcode Operand
CMA None The contents of the accumulator are CMA
complemented. No flags are affected.

A 2A CMA

0010 1010
1101 0101
D 5

Unit 4 – Assembly Language Basics 117


Logical Instruction
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CMC: Complement Carry
Instruction Description Example
Opcode Operand
CMC None The Carry flag is complemented. No other CMC
flags are affected.

STC: Set Carry


Instruction Description Example
Opcode Operand
STC None The Carry flag is set(1). No other flags are STC
affected.

Unit 4 – Assembly Language Basics 118


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

3 ANA Logical AND register or memory with accumulator 1 Byte

Logical & Bit Manipulation Instructions


4 ANI Logical AND immediate with accumulator 2 Byte
5 XRA Exclusive OR register or memory with accumulator 1 Byte
6 XRI Exclusive OR immediate with accumulator 2 Byte
7 ORA Logical OR register or memory with accumulator 1 Byte
8 ORI Logical OR immediate with accumulator 2 Byte
9 RLC Rotate accumulator left 1 Byte
10 RRC Rotate accumulator right 1 Byte
11 RAL Rotate accumulator left through carry 1 Byte
12 RAR Rotate accumulator right through carry 1 Byte
13 CMA Complement accumulator 1 Byte
14 CMC Complement carry 1 Byte
15 STC Set carry 1 Byte

Unit 4 – Assembly Language Basics 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.

1 NOP No operation 1 Byte

Control Instructions
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

Unit 4 – Assembly Language Basics 122


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

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

Unit 4 – Assembly Language Basics 123


Control Instructions
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Instruction Description Example
Opcode Operand
DI None Disable Interrupt DI
The interrupt enable flip-flop is reset and all
the interrupts except the TRAP are disabled.
No flags are affected.
EI None 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).

Unit 4 – Assembly Language Basics 124


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

Instruction Description Example


Opcode Operand
SIM None This is a multipurpose instruction used to : SIM
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.

Unit 4 – Assembly Language Basics 125


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

D7 D6 D5 D4 D3 D2 D1 D0
SOD SDE X R7.5 MSE M7.5 M6.5 M5.5

Serial Output Data Reset


It is used to transmit To set mask for RST7.5,RST 6.5,
RST 7.5 if D4=1
o/p bits. RST5.5
Ignored if D6=0 Interrupt Masked if bit=1
Serial Data Enable
If D6=1; bit D7 is
output to SOD Latch
Mask Set Enable: if 0, bits 0-2 are ignored
if 1, mask is set

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
Accumulator SOD SDE X R7.5 MSE M7.5 M6.5 M5.5

Example 1: MVI A,08H


SIM
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 0 0 0

Unit 4 – Assembly Language Basics 127


RIM: Read Interrupt Mask
Instruction Description Example
Positive Vibes:MPI is the interesting, easiest and scoring subject.

Opcode Operand
RIM None This is a multipurpose instruction used to RIM
1. Read the status of interrupts 7.5, 6.5, 5.5
2. Read serial data input bit.
It reads eight bits from accumulator with
following interpretations.
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
SID I7 I6 I5 IE 7.5 6.5 5.5

To receive To identify pending interrupts To read interrupt mask


serial data 1=pending interrupt Interrupt Masked if bit=1
0=no pending interrupt
Interrupt Enable Flag: 1=enable; 0=disable

Unit 4 – Assembly Language Basics 128


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

1 NOP No operation 1 Byte

Control Instructions
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

Unit 4 – Assembly Language Basics 129


GTU Exam Questions
Sr. Questions Marks Year
Positive Vibes:MPI is the interesting, easiest and scoring subject.

1. Explain the SIM and RIM instructions of the 8085 microprocessor. 3 S’19
2. Explain the Functions of following instructions: 3 W’19
i. RAL
ii. LDAX
iii. ADC
3. Explain the Functions of following instructions: 3 W’19
i. RLC
ii. LHLD
iii. SBB

Unit 4 – Assembly Language Basics 130


References
Book: Microprocessor Architecture, Programming, and Applications with the
Positive 8085,
Vibes:MPI is the interesting, easiest and scoring subject.

Ramesh S. Gaonkar Pub: Penram International

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

Unit 4 – Assembly Language Basics 131


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

Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy