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

Chapter-3 Instruction Set and Programming of 8085 Part1 - 1-Introduction

Uploaded by

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

Chapter-3 Instruction Set and Programming of 8085 Part1 - 1-Introduction

Uploaded by

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

Chapter-3

Instruction Set And Programming Of 8085


8085 Programming Model
Programming Model
 A microprocessor can be represented by
 Hardware Model (Physical electronic components)
 Programming Model (Information needed to write programs)
Programming Model
 Hardware Model (Physical electronic components)
 Two segments:
Programming Model
 Programming Model
 It is used for writing assembly language programs.
Some basic concept about
programming
Hierarchy of Languages
Application
Program

Machine Independent High Level Language High Level Language


Machine Specific Low Level Language
Assembly Language • Specific to Processor
MOV BL,05h • Uses symbolic names
ADD CL Machine Language to represent
MUL BH operations, registers
and memory
Micro Program locations.
1100
Control • Native to a processor,
1011
1100 executed directly by
1110 Hardware hardware
0100 • Instructions consist of
1111 binary code: 1s and 0s
Compilers and Assemblers
High Level
Language

Compiler

Assembly
Compiler
Language

Assembler

Machine
Language

Compilers translate high-level programs to


Assemblers translates assembly
machine code either directly, or Indirectly
code to machine code
via an assembler.
https://godbolt.org/
Instructions and Machine Language
 Each command of a program is called an instruction (it
instructs the computer, what to do?).
 Computers only deal with binary data, hence the instructions
must be in binary format (0’s and 1’s).
 Therefore, each Opcode is having unique bit pattern of (0’s
and 1’s).
Instruction Fields
 Assembly language instructions usually are made up of several
fields.
 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.

Opcode Operand Rd  Destination Register


MOV Rd, Rs Rs  Source Register
M, Rs
R, M M  Memory
A program with different Languages

English: Sum of A and B

A statement in a high-
level language is
High-Level Language: A + B translated typically into
several machine-level
instructions

Assembly Language: Machine


MVI A,02 Language:
MVI B,03 1001 1011 0010
ADD B 1001 1001 0011
1011 0011 0010
Advantages of High-Level Languages
 Program development is faster
 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.
Why to Learn Assembly Language?
 Accessibility to system hardware
 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
Assembler
 An assembler is a program that converts programs written in
assembly language into object files(machine language).
 Popular assemblers have emerged over the years for the Intel
family of processors. These include …
 TASM (Turbo Assembler from Borland).
 NASM (Net wide Assembler for both Windows and Linux), and
 GNUSim8085
GNUSim8085
 We will work on GNUSim8085
8085 programming
8085 Instruction Set
Classification of 8085 Instructions

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

Opcode Operand
MVI D, 8BH
Addressing Modes
 In an instruction, there my be one operand or two operands.
 The various formats of specifying operands are called
addressing modes.
 8085 instruction set has the following addressing modes
 Immediate Addressing
 Register Addressing
 Direct Addressing
 Indirect Addressing
 The detailed examples in further slides
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)
8085 Instruction
Set Classification of 8085 Instructions

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
One-byte Instruction
 One-byte instruction
 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
List of one-byte Instructions
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
Two-byte Instruction

 In two-byte instruction,
 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
List of two-byte Instructions
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
Three-byte Instruction
 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
List of three-byte Instructions
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
GTU Exam Questions
Sr Questions Marks Year
1. Explain the functions of following instructions of 8085 – state 4 W’18
the bytes occupied, number of Machine 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
8085 Instruction
Set
Classification of 8085 Instructions

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
8085 Programming
Data Transfer Instructions
Data Transfer Instructions
 Instructions copy data from source to destination.
 While copying, the contents of source is not modified.
 Data Transfer Instructions do not affect the flags.
MOV: Move data from source to destination

Instruction Description Example


Opcode Operand

MOV R d, R s • This instruction copies the MOV B, C ; BC


MOV M, R contents of the source MOV B, M;BM[HL]
MOV R, M register into the MOV M, B; M[HL]B
destination register.
• 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.
MVI: Load 8-bit to Register/Memory

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 ;
• If the operand is a memory M[HL]12
location, its location is specified
by the contents of the HL
registers.
• Two-byte instruction.
Example
 Write an assembly language program to copy data (87 H) from
B register to D register.

 Program
 MVI B, 87H ; initialize B register with the value 87H
 MOV D, B ; Copy value from B to D
 HLT ; End of the program
LDA: Load Accumulator

Instruction Description Example


Opcode Operand

LDA 16-bit • The contents of a memory LDA 2050H


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

Registers Memory
02 2000
A 0D
04 …
B C 0A ..
06 .
D E
0F 2049
H L 0D 2050
05 2051
03 2052
Example
 Write an assembly language program to copy data (87 H) which
is available at memory location 2000H to D register.

 Program
 LDA 2000H ; Copy data into A
 MOV D, A ; Copy value from A to D
 HLT ; End of the program
LDAX: Load the accumulator indirect

Instruction Description Example


Opcode Operand

LDAX Rp • The contents of a memory LDAX B ; AM[BC]


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

LDAX B ; AM[BC]

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
Addressing Modes (Revised)
 In an instruction, there my be one operand or two operands.
 The various formats of specifying operands are called
addressing modes.
 8085 instruction set has the following addressing modes
 Immediate Addressing – MVI R, Data
 Register Addressing – MOV Rd, Rs
 Direct Addressing – LDA 2050H
 Indirect Addressing - LDAX B
LXI: Load the immediate register pair

Instruction Description Example


Opcode Operand

LXI Rp, 16-bit Data The instruction loads


immediate 16-bit data into
register pair.

LXI H, 2034H A
Registers B
D
H 20 34 L
Example
 Write an assembly language program to copy data (87 H) from
memory location 2000H to D register.

 Program
 LXI B, 2000H ; Copy 20H to B and 00H to C
 LDAX B ; Copy data from ML specified by BC register into A
 MOV D, A ; Copy value from A to D
 HLT ; End of the program
STA: Store Accumulator

Instruction Description Example


Opcode Operand

STA 16-bit The contents of accumulator is STA 0002H


address copied into the memory location
specified by the operand.
16-bit memory
address
STAX: Store Accumulator Indirect

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.

02 0001
04 0002
A 0D 0A 0003 Memory
06 0004
B 00 06 C 0F 0005
Registers
D E 04 0006
05 0007
H L 03 0008
OUT: Output from Accumulator to 8-bit port

Instruction Description Example


Opcode Operand

OUT 8-bit port The contents of the OUT 0AH


address accumulator are copied into the
I/O port specified by the
operand.
IN: Input data to accumulator from with 8-bit port

Instruction Description Example


Opcode Operand

IN 8-bit port The contents of the input port IN 0AH


address designated in the operand are
read and loaded into the
accumulator.
Example
 Write an assembly language program to copy data (87 H) which
is available in B register to Output port (01H).

 Program
 MVI B, 87H ; Initialize B
 MOV A, B ; Copy value from B to A
 OUT 01H ; Send data in A to output port
 HLT ; End of the program
LHLD: Load H and L registers direct

Instruction Description Example


Opcode Operand

LHLD 16-bit • The instruction copies contents of LHLD 2050H


address the memory location pointed out by LHLD 0006H
the 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.
Example: LHLD Instruction
LHLD 0006H

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

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
SHLD 0002H
0001
D3 0002
H A2 D3 L A2 0003
0004
XCHG: Exchange H and L with D and E

Instruction Description Example


Opcode Operand

XCHG None The contents of register H are XCHG


exchanged with the contents of
register D, and the contents of
register L are exchanged with
the contents of register E.

D A2 03 E D D3 08 E
H D3 08 L H A2 03 L
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
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 Year
1. Explain the PUSH and POP instructions of the 8085 4 W’17
microprocessor with example.
2. Explain the following instructions of the 8085 microprocessor 7 W’17
with suitable example:
STA, LDAX, XTHL
3. Explain 8085 data transfer instructions with suitable examples. 7 S’18
4. Define opcode and operand, and specify the opcode and the 3 W’18
operand in the instruction MOV H, L
5. Explain the following instructions of the 8085 microprocessor 4 S’19
with
suitable example: LHLD, SPHL, LDAX, XTHL
6. The memory location 2070 H holds the data byte F2H.Write 4 W’19
instructions to transfer the data byte to the accumulator using
three different opcodes: MOV, LDAX, and LDA.
7. Register D contains 72H.Illustrate the instructions MOV and STAX 4 W’19
to copy the contents of register D into memory location 8020H
using indirect addressing.
Example
 The memory location 2070 H holds the data byte F2H. Write
instructions to transfer the data byte to the accumulator using
three different opcodes: MOV, LDAX, and LDA.
 Program
 MVI A, F2H ; Initialize A
 STA 2070H ; Store data (F2H) to 2070H
 ;using MOV
 LXI H, 2070H ; Prepare HL with memory address
 MOV A, M ; Copy value from M to A
 ; using LDAX
 LXI B, 2070H ; Prepare BC pair for memory address
 LDAX B ; Copy content of ML whose address available to B to A
 ;using LDA
 LDA 2020H
 HLT ; End of the program
Example
 Register D contains 72H. Illustrate the instructions MOV and
STAX to copy the contents of register D into memory location
8020H using indirect addressing.
 Program
Classification of 8085 Instructions

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
8085 Programming
Arithmetic Instructions
Arithmetic Instructions
1 Add register or memory, to the accumulator 1 Byte
ADD R/M
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
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 R
p
Increment register pair by 1 1 Byte
12 DCR R/M Decrement the register or the memory by 1 1 Byte
13 DCX R
p
Decrement register pair by 1 1 Byte
14 DAA Decimal adjust accumulator 1 Byte
Arithmetic Instruction
 Addition
 8085 performs addition with 8-bit binary numbers and
stores the sum in Accumulator (A).
 If sum is larger than FFH(8-bit), then CY flag is set.
ADD: Add register/memory to accumulator

Instruction Description Example


Opcode Operand

ADD R/M • The contents of the operand ADD B; A = A + B


(register or memory) are added to ADD M; A = A + M[HL]
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.
Example : Addition
ADI: Add immediate 8-bit with accumulator

Instruction Description Example


Opcode Operand

ADI 8-bit • The 8-bit data (operand) is added ADI 03; A = A + 03h
data 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.
Example : Addition
Example : Addition
ADC: Add register to accumulator with carry
Instruction Description Example
Opcode Operand

ADC R/M • The contents of the operand ADC B; A = A + B + CY


(register or memory) and the ADC M; A = A + M[HL]+CY
Carry flag are 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.
ACI: Add immediate 8-bit to accumulator with
carry
Instruction Description Example
Opcode Operand

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.
DAD: Add register pair to H and L registers

Instruction Description Example


Opcode Operand

DAD Rp • The 16-bit contents of the DAD B


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

DAD B

Registers
A
B 02 08 C
D E + 02 08
H 02 03 L 02 03

04 0B
04 0B
Arithmetic Instruction
 Subtraction
 8085 performs subtraction by using 2’s complement.
 The subtraction can be performed by SUB/ SUI on 8-bit
data.
 In any case, minuend (the number from which to subtract)
is in A.
 If result after subtraction is 0, then Zero flag is set.
SUB: Subtract register/memory from
accumulator
Instruction Description Example
Opcode Operand

SUB R/M • The contents of the operand SUB B ; A=A-B


(register or memory) is subtracted SUB M ; A=A-M[HL]
from the contents of the
accumulator, and the result is
stored in the accumulator.
• If the operand is a memory
location, its location is specified by
the contents of the HL registers.
• All flags are modified to reflect the
result of the subtraction.
Example : Subtraction
SUI: Subtract immediate 8-bit from accumulator

Instruction Description Example


Opcode Operand

SUI 8-bit • The 8-bit data (operand) is SUI 08h; A = A - 08h


data subtracted from the contents of
the accumulator and the result is
stored in the accumulator.
SBB: Subtract source & borrow from
accumulator

Instruction Description Example


Opcode Operand

SBB R/M • The contents of the operand SBB B; A=A - (B+CY)


(register or memory) and the SBB M; A=A-(M[HL]
Borrow flag are subtracted from +CY)
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.
SBI: Subtract immediate from accumulator
with borrow

Instruction Description Example


Opcode Operand

SBI 8-bit • The 8-bit data (operand) and the SBI 08h; A=A -
data borrow (CY) are subtracted from (08h+CY)
the contents of the accumulator
and the result is stored in the
accumulator.
INR: Increment register/memory by 1

Instruction Description Example


Opcode Operand

INR R/M • The contents of the designated INR B;B=B+01


register or memory is incremented INR M ;M[HL]=M[HL]
by 1 and the result is stored at the +01
same place.
• If the operand is a memory
location, its location is specified by
the contents of the HL registers.
INX: Increment register pair by 1

Instruction Description Example


Opcode Operand

INX Rp The contents of the designated INX D; DE=DE+0001


register pair is incremented by 1 and
the result is stored at the same place.
DCR: Decrement register/ memory by 1

Instruction Description Example


Opcode Operand

DCR R/M • The contents of the designated DCR B;B=B-01


register or memory is DCR M;M[HL]=M[HL]-01
decremented by 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.
DCX: Decrement register pair by 1

Instruction Description Example


Opcode Operand

DCX Rp The contents of the designated DCX B; BC=BC- 0001


register pair is decremented by 1 and DCX D; DE=DE- 0001
their result is stored at the same
place.
Example
 Write a program to add two 8-bit numbers stored in B and C
registers and store result into D register.
 Program
 MVI B 05H
 MVI C 06H
 MOV A, B
 ADD C
 MOV D, A
Example
 Write a program to add two 16-bit numbers stored in BC and DE
register-pairs and store result into memory location 2000H,
2001H .
 Program
 MVI B , 05H
 MVI C, 02H
 MVI D, 06H
 MVI E, 01H
 MOV A, C
 ADD E ; lower –order answer in A
 STA 2000H
 MOV A, B
 ADC D
 STA 2001H
 HLT
Example
 Write a program to subtract 12H from 45H using simple
subtraction method and 2’s complement method.
 Program
 MVI A, 45H
 MVI B, 12H
 SUB B ; Simple subtraction
 HLT

 MVI A, 12H ; using 2’s complement


 CMA
 INR A
 MVI B, 45H
 ADD B
 HLT
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
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 R
p
Increment register pair by 1 1 Byte
12 DCR R/M Decrement the register or the memory by 1 1 Byte
13 DCX R
p
Decrement register pair by 1 1 Byte
14 DAA Decimal adjust accumulator 1 Byte

You might also like