Escolar Documentos
Profissional Documentos
Cultura Documentos
Microprocessor
Unit4
Unit4 Assembly
Assembly &
Microprocessor Language
& Interfacing
Language Basics
Interfacing
Basics2150707 1
-- 2150707 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Subject Overview
Sr. No. Unit % Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 10%
4 Assembly Language Basics 10%
5 8085 Assembly Language Programs 10%
6 Stack & Subroutines 10%
7 I/O Interfacing 15%
8 Advanced Microprocessors 20%
9 SUN SPARC Microprocessor 5%
10 ARM Processor 5%
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 2 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Basics
3
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 3 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Hierarchy of Languages
Application Program
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 4 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Compilers and Assemblers
High Level Language
Compiler
Assembler
Machine Language
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 6 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Instruction Fields
Assembly language instructions usually are made up of several
fields.
Each field specifies different information for the computer.
The major two fields are:
1. Opcode field which stands for operation code and it specifies the
particular operation that is 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.
The source/destination of operands can be a constant, the memory or one
of the general-purpose registers.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 7 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Instruction Fields
Opcode Operand
MOV Rd, Rs
M, Rs
Rs, M
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 8 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Translating Languages
English: D is assigned the sum of A and B
High-Level Language: D = A + B
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 9 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Advantages of High-Level Languages
Program development is faster
High-level statements: fewer instructions to code
Program maintenance is easier
For the same above reasons
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
However, Assembly language programs are not portable
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 10 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Why to Learn Assembly Language?
Accessibility to system hardware
Assembly Language is useful for implementing system software
Also useful for small embedded system applications
Space and Time efficiency
Understanding sources of program inefficiency
Tuning program performance
Writing compact code
It is helpful for:
compiler writing
programming microcontrollers
device drivers
system design
low-level numeric routines
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 11 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Why to Learn Assembly Language?
Writing assembly programs gives the computer designer the
needed deep understanding of the instruction set and how to
design one
To be able to write compilers for HLLs, we need to be expert with
the machine language. Assembly programming provides this
experience
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 12 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
1. Assembler
2. Linker
3. Debugger
4. Editor
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 13 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
Assembler
An assembler is a program that converts source-code programs
written in assembly language into object files in machine language
Popular assemblers have emerged over the years for the Intel
family of processors. These include
TASM (Turbo Assembler from Borland)
NASM (Netwide Assembler for both Windows and Linux), and
GNU assembler distributed by the free software foundation
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 14 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
Linker
A linker program is required to produce executable files
It combines your program's object file created by the assembler
with other object files and link libraries, and produces a single
executable program
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 15 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
Assemble and Link Process
Source Object
File Assembler File
Link
Source Object
Assembler Libraries
File File
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 16 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
Debugger
Allows you to trace the execution of a program
Allows you to view code, memory, registers, etc.
Example: 32-bit Windows debugger
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 17 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Assembly Language Programming Tools
Editor
Allows you to create assembly language source files
Some editors provide syntax highlighting features and can be
customized as a programming environment
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 18 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification
of
8085 Instructions
19
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 19 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Arithmetic Instructions
Branch Instructions
Control Instructions
Three-byte Instructions
20
Classification of 8085 Instructions
An instruction is a binary pattern designed inside a microprocessor
to perform a specific function.
8085 has 246 instructions.
Each instruction is represented by an 8-bit binary value.
These 8-bits of binary value is called Op-Code.
The entire group of instructions that a microprocessor supports is
called Instruction Set.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 21 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Instruction Set
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
Unit-4 Assembly
Assembly Language
Language Basics
Basics 22 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
General Terms
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
Unit-4 Assembly
Assembly Language
Language Basics
Basics 23 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Arithmetic Instructions
Branch Instructions
Control Instructions
Three-byte Instructions
24
1-byte Instruction
1-byte instructions includes Opcode and Operand in the same byte.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 25 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Arithmetic Instructions
Branch Instructions
Control Instructions
Three-byte Instructions
26
2-byte Instruction
In 2-byte instruction,
1st Byte : Specifies Operation code
2nd Byte: Specifies the Operand
Instruction Binary Code Hexa Code
Opcode Operand
MVI A,32H 0011 1110 3E: 1st Byte
0011 0010 32: 2nd Byte
MVI B,F2H 0000 0110 06: 1st Byte
1111 0010 F2: 2nd Byte
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 27 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Arithmetic Instructions
Branch Instructions
Control Instructions
Three-byte Instructions
28
3-byte Instruction
In 3-byte instruction,
1st Byte: Specifies Opcode
2nd Byte: Specifies lower order 8-bit address
3rd Byte: Specifies higher order 8-bit address
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 29 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
30
Classification of 8085 Instructions
31
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 31 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Data Transfer Instructions
These instructions copy data from source to destination.
While copying, the contents of source are not modified.
Data Transfer Instructions do not affects the flags.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 32 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
MOV: Move
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 33 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
MVI: Load 8-bit to Register/Memory
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 34 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
LDA: Load Accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 35 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
LDAX: Load the accumulator indirect
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 36 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
LDAX Instruction
Registers Memory
02 0001
A 0D
04 0002
B 00 06 C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008
MVI B,00H
MVI C,06H
LDAX B ; BC pair
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 37 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
LXI: Load the register pair immediate
LXI Rp, 16-bit The instruction loads 16-bit data in LXI H, 2034H
Data the register pair designated in the
operand.
A
B
D
H 20 34 L
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 38 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
STA: Store Accumulator
STA 16-bit The contents of the accumulator are MVI A, 09H data
address copied into the memory location STA 0002H
specified by the operand.
16bit memory address
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 39 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
STAX: Store Accumulator Indirect
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 40 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
LHLD: Load H and L registers direct
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 41 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
LHLD Instruction
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
LHLD 0006H
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 42 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
SHLD: Store H and L registers direct
Memory
0001
0002 SP
H A2 D3 L 0003 SP
0004
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 43 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
XCHG: Exchange H and L with D and E
D A2 03 E D D3 08 E
XCHG
H D3 08 L H A2 03 L
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 44 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
SPHL: Copy H and L registers to the stack pointer
SP (16)
H A2 D3 L SPHL
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 45 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
XTHL: Exchange H and L with top of stack
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 46 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
PUSH: Push the register pair onto the stack
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 47 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
PUSH Instruction
Registers STACK
SP 23 0008
A
SP 06 0007
B 06 40 C SP 40 0006
D 0005
E
0004
H L 0003
0002
PUSH B
0001
SP <- SP-1
SP <- B ;transfer high order bit to TOS
SP <- SP-1
SP <- C ;transfer low order bit to TOS
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 48 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
POP : Pop off stack to the register pair
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 49 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
POP Instruction
Registers STACK
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
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 50 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
OUT: Output from Accumulator to 8-bit port address
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 51 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Data Transfer Instructions
IN: Input data to accumulator from a port with 8-bit address
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 52 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
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
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
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
54
Arithmetic Instruction
ADD: Add register or memory, to the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 55 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
ADC: Add register to the accumulator with carry
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 56 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
ADC: Add register to the accumulator with carry
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 57 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
ADI: Add the immediate to the accumulator
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
Unit-4 Assembly
Assembly Language
Language Basics
Basics 58 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
ACI: Add the immediate to the accumulator with carry
ACI 8-bit The 8-bit data (operand) and the ACI 03; A = A + 03h + CY
data Carry 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
Unit-4 Assembly
Assembly Language
Language Basics
Basics 59 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
DAD : Add the register pair to H and L registers
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 60 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
DAD Instruction
Registers
A
B 02 08 C
D E +
H 02
04 03
0B L 02 03
04 0B
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 61 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
SUB : Subtract the register or the memory from the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 62 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
SBB : Subtract the source and borrow from the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 63 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
SUI : Subtract the immediate from the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 64 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
SBI : Subtract the immediate from the accumulator with borrow
SBI 8-bit The 8-bit data (operand) and the SBI 08h; A=A - (08h+CY)
data Borrow flag are subtracted from the
contents of the accumulator and the
result is stored in the accumulator.
All flags are modified to reflect the
result of the subtraction.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 65 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
INR: Increment the register or the memory by 1
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 66 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
INX : Increment register pair by 1
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 67 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
DCR: Decrement the register or the memory by 1
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 68 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
DCX: Decrement register pair by 1
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 69 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Arithmetic Instruction
DAA: Decimal adjust accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 70 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
DAA Instruction
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
Unit-4 Assembly
Assembly Language
Language Basics
Basics 71 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
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 2 BYTE
4 ACI 8-bit data Add the immediate to the accumulator with carry 2 BYTE
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
72
Classification of 8085 Instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
73
Classification of 8085 Instructions
Branching Instructions
74
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 74 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
JMP: Jump unconditionally
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 75 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
Jump Conditionally
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 76 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
CALL Conditionally
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 77 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
RET: Return from subroutine unconditionally
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 78 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
Return from Subroutine
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 79 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
PCHL: Load the program counter with HL contents
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 80 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
RST : Restart
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 81 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Branching Instruction
The 8085 has additionally 4 interrupts, which can generate RST instructions
internally and doesnt require any external hardware.
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 82 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
83
Classification of 8085 Instructions
Logical Instructions
84
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 84 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
CMP: Compare the register or memory with the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 85 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
CPI: Compare immediate with the accumulator
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 86 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
ANA: Logical AND register or memory with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 87 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
ANI: Logical AND immediate with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 88 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
XRA: Exclusive OR register or memory with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 89 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
XRI: Exclusive OR immediate with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 90 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
ORA: Logical OR register or memory with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 91 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
ORI: Logical OR immediate with the accumulator
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 92 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RLC: Rotate the accumulator left
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 93 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RLC
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
11 0 1 0 1 0 0 0
0 1 0 1 0 0 0 1
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 94 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RRC: Rotate the accumulator right
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 95 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RRC
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 00
1 0 1 0 1 0 0
CY
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 96 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RAL: Rotate the accumulator left through carry
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 97 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RAL
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
11 0 1 0 1 0 0 0
0 1 0 1 0 0 0
CY
0
Rotate the accumulator lef through carry
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 98 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RAR: Rotate the accumulator right through carry
Instruction Description Example
Opcode Operand
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 99 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
RAR
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 1 0 0 00
1 0 1 0 1 0 0
CY
1
100
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
CMA: Complement accumulator
Instruction Description Example
Opcode Operand
A 2A CMA
0010 1010
1101 0101
D5
101
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Logical Instruction
CMC: Complement Carry
Instruction Description Example
Opcode Operand
102
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Classification of 8085 Instructions
Arithmetic Instructions
Branch Instructions
Control Instructions
Three-byte Instructions
103
Classification of 8085 Instructions
Control Instructions
104
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 104 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Control Instructions
Instruction Description Example
Opcode Operand
105
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Control Instructions
Instruction Description Example
Opcode Operand
106
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Control Instruction
SIM: Set Interrupt Mask
Instruction Description Example
Opcode Operand
107
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
SIM Instruction
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 To set mask for RST7.5,RST 6.5, RST5.5
It is used to RST 7.5 if D4=1 Interrupt Masked if bit=1
transmit o/p bits.
Ignored if D6=0
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
108
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
SIM Instruction
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
SOD SDE X R7.5 MSE M7.5 M6.5 M5.5
109
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Control Instruction
RIM: Read Interrupt Mask
Instruction Description Example
Opcode Operand
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
SID I7 I6 I5 IE 7.5 6.5 5.5
111
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
112
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 112 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Immediate Addressing Mode
113
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Immediate Addressing Mode
114
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Direct Addressing Mode
115
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Register Addressing Mode
116
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Indirect Addressing Mode
117
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Addressing Modes in 8085
Implicit/Implied Addressing Mode
118
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085
Assembly Language Programs
119
Unit4
Unit4 Assembly
Assembly Language
Language Basics
Basics 119 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Writing Assembly Language Programs
The steps to write Assembly Language Programs are as follows:
120
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Writing Assembly Language Programs
Documentation
Appropriate comments are critical for conveying the logic behind
the program.
The comment should explain what is intended; they should not
explain mnemonics.
Comment is optional.
Example:
MOV A,B ; Move data from B to A
MOV A,B ; send data to accumulator for I/O processing
121
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Writing Assembly Language Programs
Program Execution
Machine code can be loaded in R/W memory, with reference to
starting memory location.
Execution can be done in two ways:
1. Execute entire code on click
2. Single step execution
It will execute one instruction at a time.
We can observe the content of register and flag after execution of each
instruction.
122
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Writing Assembly Language Programs
Debugging Program
Debug a program is similar to troubleshooting hardware.
In program, result is generally binary: either it works or it doesnt.
If the code doesnt work, it is essential to search carefully for
errors in programming logic, machine codes and execution.
How to Debug machine code:
Translating assembly to machine code is similar to building a
circuit.
Following errors are common:
1. Selecting a wrong code
2. Specifying the wrong jump location
3. Writing memory address in decimal, thus specifying wrong jump location
4. Writing lower order and higher order bits in wrong sequence.
123
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Adding Two 8-bit Numbers
Write a program to add data at 1005H &
1006H memory location and store the result at Start
1007H memory location.
Transfer 16-bit
address to HL Pair
1. LXI H,1005 ; to retrive m/m addr
2. MOV A,M ; retrieve m/m content Data Transfer:A <- M[HL]
3. INX H ;increment memeory to 1006H
HL=HL + 1
4. ADD M;add accumulator with M[1006]
5. STA 1007 A = A + M[HL]
6. HLT ; HLT program
Store result
[1007] <- A
End
124
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to load register B with 37H and display number at
the output Port 01
MVI B,37; B <- 37H
MOV A,B ; A <- B for I/O processing
OUT 01 ; PORT 01 <- A
HLT
125
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing Cycle required by 8085 Instruction
Operation T-States
Opcode Fetch 4-6T
Operand Fetch 3T
Memory Read 3T
Memory Write 3T
I/O Read 3T
I/O Write 3T
Operation M/C
Fetch (F) 1
Memory Read (MEMR) 1
Memory Write (MEMW) 1
I/O Read (IOR) 1
I/O Write (IOW) 1
127
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
1. MOV B , D
Machine Cycle:
1(F)= 1 Machine Cycle
Timing Cycle:
= 4T(Opcode Fetch)
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
2. MVI C ,17H
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
3. MVI M , 25H
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
4. MOV A,M
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
4. MOV M, A
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
5. NOP
133
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
6. HLT : Halt and enter wait state
134
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
7. IN 18H
135
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
8. OUT 19H
136
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
9. ADD B
Machine Cycle: Fetch
= 1 Machine Cycle
Timing Cycle:
= 4T(Opcode Fetch)
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
10. ADI 26H
138
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
11. ADD M
139
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
12. SUB C
Timing Cycle:
= 4T(Opcode Fetch)
140
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
13. SUI 26H
141
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
14. SUB M
142
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
15. LDA 2030H
143
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
16. POP RP : POP B
144
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
16. PUSH RP : PUSH B
145
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
LHLD Instruction
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
LHLD 0006H
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
17. LHLD 2034H
147
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
12. RAR
Timing Cycle:
= 4T(Opcode Fetch)
148
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
18. XTHL
149
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
19. CALL 2030H
150
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
20. RET
151
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Timing and Machine Cycle
Find Timing Cycle, Machine Cycle and Byte Size of following Instructions
1. LDAX B
2. SHLD 2470
3. SPHL
4. DAA
5. INR R/M
6. JMP
7. PCHL
8. CMP R/M
9. RRC
10. RIM
11. SIM
12. ORA R/M
13. XCHG
14. DI
15. EI
152
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Sr. No. Instruction Byte Size Machine Cycle T-States
1. LDAX B 1 F+R=2 4T+3T=7T
2. SHLD 2470 3 F+R+R+W+W=5 4T+3T+3T+3T+3T=16T
3. SPHL 1 F=1 =6T
4. DAA 1 F=1 =4T
5. INR R 1 F=1 =4T
INR M 1 F+R+W=3 4T+3T+3T=10T
6. JMP 2030 3 F+R+R=3 4T+3T+3T=10T
7. PCHL 1 F=1 =6T
8. CMP R 1 F=1 =4T
CMP M 1 F+R=2 4T+3T=7T
9. RRC 1 F=1 =4T
10. RIM 1 F=1 =4T
Sr. No. Instruction Byte Size Machine Cycle T-States
11. SIM 1 F=1 =4T
12. ORA R 1 F=1 =4T
ORA M 1 F+R=2 4T+3T=7T
13. XCHG 1 F=1 =4T
14. DI 1 F=1 =4T
15. EI 1 F=1 =4T
154
Assignment 3: Unit 4
1. Differentiate the following
i. Assembly Language and Machine Language
ii. Differentiate JMP , CALL and RET instruction
2. What is an Assembler? Is Assembly Language portable?
3. Explain following types of interrupt:
i. Level triggered and edge triggered Interrupt
ii. Vectored and Non vectored Interrupt
iii. Maskable and non-maskable Interrupt
4. What does 2nd byte in IN and OUT instruction specifies?
5. Draw and explain PSW in 8085.
6. Explain RIM and SIM Control Instructions.
7. What will happen if HLT instruction is executed in processor?
Unit-4
Unit-4 Assembly
Assembly Language
Language Basics
Basics 155 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology