MPI GTU Study Material Presentations Unit-4 17032021071018AM
MPI GTU Study Material Presentations Unit-4 17032021071018AM
(MPI)
GTU # 3160712
Unit-4:
Assembly
Language
Programming Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Basics
Hierarchy of Languages
Compilers and Assemblers
Instructions and Machine Language
Advantages of High-Level Languages
Why to Learn Assembly Language?
Assembly Language Programming
Tools
Classification of 8085 Instructions
Based on Byte Size
Based on Function
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Hierarchy of Languages
Hierarchy of Languages
Application Positive Vibes:MPI is the interesting, easiest and scoring
Program subject.
High Level
Machine Independent Language High Level Language
• Assembly
Machine Specific Assembly Low Level Language
language is a
Language low-level
1100
MOV 1011 Machine programming
• language
Native to a
BL,05h 1100 Language
ADD CL 1110 processor:for a
designed
MUL BH 0100 executed
specific type of
1111 Micro Program directly by
processor.
Control hardware
• Uses symbolic
• names
Instructions to
Hardware consist of
represent
binary code:
operations,
1s and 0s and
registers
memory
Prof. Swati R Sharma
locations.
Unit 4 – Assembly Language Basics 5
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Compilers and
Assemblers
Compilers and Assemblers
High Level Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Language
Compil
er
Compil Assembly
er Language
Assemb
ler
Machine
Language
Compilers translate high-level programs
Assemblers to assembly code to
translates
machine code machine code
either directly, or Indirectly via an assembler
Instructions and
Machine Language
Instructions and Machine Language
Each command of a program is called an instruction (it instructs the
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Rd Destination Register
Rs Source Register
M Memory
High-Level Language: A + B
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.
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
Source Object
File Assembler File
Link
Source Object
Assembler Libraries
File File
Classification of
8085 Instructions
Classification of 8085 Instructions
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Classification of 8085 instructions
An instruction is a binary pattern designed inside a microprocessor to
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
perform a specific function.
Each instruction is represented by an 8-bit binary value called Op-Code.
The entire group of instructions that a microprocessor supports is known
as an Instruction Set.
MVI D, 8BH
Opco Opera
de nd
byte.
Instruction Binary Code Hexa Code
Opcode Operand
MOV C,A 0100 1111 4FH
ADD B 1000 0000 80H
CMA 0010 1111 2FH
.
1 MOV 13 SBB R/M 25 RNZ 37 CMA
dest.,src
2 LDAX RP 14 INR R/M 26 RPE 38 CMC
(B/D)
3 STAX RP 15 INX RP 27 RPO 39 STC
4 XCHG 16 DCR R/M 28 RST 0-7 40 NOP
5 SPHL 17 DCX RP 29 CMP R/M 41 HLT
6 XTHL 18 DAA 30 ANA R/M 42 DI
7 PUSH RP 19 RET 31 XRA R/M 43 EI
8 POP RP 20 RC 32 ORA R/M 44 RIM
9 ADD R/M 21 RNC 33 RLC 45 SIM
10 ADC R/M 22 RP 34 RRC
11 DAD 23 RM 35 RAL
12 SUB R/M 24 RZ 36 RAR
Prof. Swati R Sharma Unit 4 – Assembly Language Basics 31
Two-byte Instruction
In two-byte instruction, Positive Vibes:MPI is the interesting, easiest and scoring
subject.
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
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.
AM[BC]
Register Memor
s y 02 0001
A
04 0002
B 00 06 C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008
0006H
Register Memor
s y
02 0001
A
04 0002
B C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008
D A2 03 E D D3 08 E
H D3 08 L H A2 03 L
Register Memor
s y 0001
3F 0002 SP
H A2 D3 L 0003
2C SP
0004
Register Memo
s SP ry03 0008
A
SP 06 0007
B 06 40 C SP 40 0006
D 0005
E
0004
H L 0003
0002
0001
POP B
C <- SP ; transfer to low order bit
from TOS
SP <- SP+1
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Arithmetic Instructions
1 ADD R/M Add register or memory, to the 1 Byte
accumulator
2 ADC R/M Add register to the accumulator with 1 Byte
carry Positive Vibes:MPI is the interesting, easiest and scoring
3 ADI 8-bit Add the immediate to the accumulator
subject. 2 Byte
Arithmetic Instructions
4 data
ACI 8-bit Add the immediate to the accumulator 2 Byte
data with carry
5 DAD R p
Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from 1 Byte
accumulator
7 SBB R/M Subtract the source and borrow from 1 Byte
accumulator
8 SUI 8-bit Subtract the immediate from the 2 Byte
data accumulator
9 SBI 8-bit Subtract immediate from accumulator 2 Byte
1 data with borrow
INR R/M Increment the register or the memory by 1 Byte
0 1
1 INX Rp Increment register pair by 1 1 Byte
1
1 DCR R/M Decrement the register or the memory by 1 Byte
2 1
1 DCX Rp Decrement register pair by 1 1 Byte
3
1 DAA Decimal adjust accumulator 1 Byte
4
Opcod Operan
e d
ADC R/M • The contents of the operand ADC B; A = A + B
(register or memory) and the + CY
ADC M; A = A +
Carry flag are added to the
M[HL]+CY
contents of the accumulator
and the result is stored in the
accumulator.
• If the operand is a memory
location, its location is
specified by the contents of
the HL registers.
• All flags are modified to
reflect the result of the
addition.
A
B 02 08 C
D E +
H 02
04 0B
03 L 02 03
04 0B
DAD B
Register
s 1 11
A 2 001 1010
A 0
B C +0000 01
10
D E 0 01 1 0000
H L
Valid BCD
number
3
0
Arithmetic Instructions
4 data
ACI 8-bit Add the immediate to the accumulator 2 Byte
data with carry
5 DAD R p
Add the register pair to H and L registers 1 Byte
6 SUB R/M Subtract the register/memory from 1 Byte
accumulator
7 SBB R/M Subtract the source and borrow from 1 Byte
accumulator
8 SUI 8-bit Subtract the immediate from the 2 Byte
data accumulator
9 SBI 8-bit Subtract immediate from accumulator 2 Byte
1 data with borrow
INR R/M Increment the register or the memory by 1 Byte
0 1
1 INX Rp Increment register pair by 1 1 Byte
1
1 DCR R/M Decrement the register or the memory by 1 Byte
2 1
1 DCX Rp Decrement register pair by 1 1 Byte
3
1 DAA Decimal adjust accumulator 1 Byte
4
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Branch Instructions
1 JMP Jump unconditionally 3 Byte
2 JC Jump on carry 3 Byte
3 JNC Jump on no carry 3 Byte
4 JP Jump on positive 3 Byte
5 JM Jump on minus 3 Byte Positive Vibes:MPI is the interesting, easiest and scoring
subject.
6 JZ Jump on zero 3 Byte
7 JNZ Jump on no zero 3 Byte
8 JPE Jump on parity even 3 Byte
9 JPO Jump on parity odd 3 Byte
1 CALL Call unconditionally 3 Byte
Branch Instructions
0
1 CC Call on carry 3 Byte
1
1 CNC Call on no carry 3 Byte
2
1 CP Call on positive 3 Byte
3
1 CM Call on minus 3 Byte
4
1 CZ Call on zero 3 Byte
5
1 CNZ Call on no zero 3 Byte
6
1 CPE Call on parity even 3 Byte
7
1 CPO Call on parity odd 3 Byte
8
1 RET Return unconditionally 1 Byte
9
JMP: Jump unconditionally
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Opco Operand
de
CC 16-bit Call on Carry, Flag Status: CC 2030H
address
CNC 16-bit CY=1
Call on No Carry, Flag Status: CNC 2030H
address
CZ 16-bit CY=0
Call on Zero, Flag Status: CZ 2030H
address
CNZ 16-bit Z=1
Call on No Zero, Flag Status: CNZ 2030H
address
CP 16-bit Z=0
Call on Positive, Flag Status: CP 2030H
address
CM 16-bit S=0
Call on Minus, Flag Status: CM 2030H
address
CPE 16-bit S=1
Call on Parity Even, CPE 2030H
address Flag Status: P=1
CPO 16-bit Call on Parity Odd, CPO 2030H
address Flag Status: P=0
Opcod Operan e
e d RST 5
RST 0- The RST instruction is used as software
7(N) instructions in a program to transfer the
program execution to one of the
following eight locations.
Instruction Restart Address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
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.
Opcod Operan
e d CMP B
CMP R/M The contents of the operand
(register or memory) is CMP M
compared with the contents of
the accumulator. Both contents
are preserved. The result of the
comparison is shown by setting
the flags:
1. if (A) < (reg/mem): carry flag
is set(1).
2. if (A) = (reg/mem): zero flag
is set(1).
3. if (A) > (reg/mem): carry and
zero flags are reset(0).
Opcod Operan
e d CPI 89H
CPI 8-bit • The second byte data is
data compared with the contents
of the accumulator.
• The values being compared
remain unchanged. The result
of the comparison is shown
by setting the flags:
1. if (A) < data: carry flag is
set(1).
2. if (A) = data: zero flag is
set(1).
3. if (A) > data: carry and zero
flags are reset(0).
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
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
CY
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
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
CY
1
A 2A CMA
001 1010
0
1100101
1
D 5
Control Instructions
Three-byte Instructions
Requires three memory locations
to perform an operation
E.g. JMP, CALL
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Control Instructions
Positive Vibes:MPI is the interesting, easiest and scoring
subject.
Control Instructions
1 NOP No operation 1 Byte
2 HLT Halt 1 Byte
3 DI Disable interrupts 1 Byte
4 EI Enable interrupts 1 Byte
5 RIM Read interrupt mask 1 Byte
6 SIM Set interrupt mask 1 Byte
Opcod Operan
e d NOP
NOP None • No operation is performed. The
instruction is fetched and
decoded. However no operation is
executed.
• It is used to increase processing
time of execution.
• 1 CPU cycle is "wasted" to
HLT None execute
The CPU afinishes
NOP instruction.
executing the HLT
current instruction and stops further
execution. An interrupt or reset is
necessary to exit from the halt state.
D7 D6 D5 D4 D3 D2 D1 D0
SOD SDE X R7.5 MS M7. M6.
E 5 5 M5.
Serial Output Reset 5
Data To set mask for RST7.5,RST
RST 7.5 if
It is used to 6.5, RST5.5
D4=1
transmit o/p Interrupt Masked if bit=1
bits. Serial Data
Ignored if D6=0 Enable
If D6=1; bit D7 is
output to SOD Mask Set Enable: if 0, bits 0-2
Latch are ignored
if 1, mask is set
D7 D6 D5 D4 D3 D2 D1 D0
Accumul SOD SDE X R7.5 MS M7. M6. M5.
ator E 5 5 5
Example 1: MVI A,08H
SIM
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 0 0 0
Control Instructions
1 NOP No operation 1 Byte
2 HLT Halt 1 Byte
3 DI Disable interrupts 1 Byte
4 EI Enable interrupts 1 Byte
5 RIM Read interrupt mask 1 Byte
6 SIM Set interrupt mask 1 Byte
Mobile 8085 and 8086 Microprocessor Opcodes app from Play Store:
Applicatio http://tiny.cc/aopcodes
n
Thank You