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

unit 5 Assembly Language-1

Unit

Uploaded by

Anant Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

unit 5 Assembly Language-1

Unit

Uploaded by

Anant Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

8085 Data-transfer Instruction

Following is the table showing the list of Data-transfer instructions with their meanings.

Opcod
Operand Meaning Explanation
e

Rd, Sc Copy from the source This instruction copies the contents of the source r
MOV M, Sc (Sc) to the into the destination register without any alteration.
Dt, M destination(Dt) Example − MOV K, L

The 8-bit data is stored in the destination regis


Rd, data
MVI Move immediate 8-bit memory.
M, data
Example − MVI K, 55L

The contents of a memory location, specified by a


LDA 16-bit address Load the accumulator address in the operand, are copied to the accumulator
Example − LDA 2034K

The contents of the designated register pair poin


Load the accumulator memory location. This instruction copies the conte
LDAX B/D Reg. pair
indirect that memory location into the accumulator.
Example − LDAX K

The instruction loads 16-bit data in the registe


Load the register pair
LXI Reg. pair, 16-bit data designated in the register or the memory.
immediate
Example − LXI K, 3225L

The instruction copies the contents of the memory lo


Load H and L registers pointed out by the address into register L and copi
LHLD 16-bit address
direct contents of the next memory location into register H.
Example − LHLD 3225K

The contents of the accumulator are copied int


memory location specified by the operand.
This is a 3-byte instruction, the second byte specifi
STA 16-bit address 16-bit address
low-order address and the third byte specifies the
order address.
Example − STA 325K

The contents of the accumulator are copied int


Store the accumulator
STAX 16-bit address memory location specified by the contents of the oper
indirect
Example − STAX K

SHLD 16-bit address Store H and L registers The contents of register L are stored in the m
direct location specified by the 16-bit address in the operan
the contents of H register are stored into the next m
location by incrementing the operand.
This is a 3-byte instruction, the second byte specifi
low-order address and the third byte specifies the
order address.
Example − SHLD 3225K

The contents of register H are exchanged with the co


Exchange H and L with of register D, and the contents of register L are exch
XCHG None
D and E with the contents of register E.
Example − XCHG

The instruction loads the contents of the H and L re


into the stack pointer register. The contents of
Copy H and L registers
SPHL None register provide the high-order address and the conte
to the stack pointer
the L register provide the low-order address.
Example − SPHL

The contents of the L register are exchanged with the


location pointed out by the contents of the stack p
Exchange H and L with register.
XTHL None
top of stack The contents of the H register are exchanged with th
stack location (SP+1).
Example − XTHL

The contents of the register pair designated in the op


are copied onto the stack in the following sequence.
The stack pointer register is decremented and the co
of the high order register (B, D, H, A) are copied in
Push the register pair
PUSH Reg. pair location.
onto the stack
The stack pointer register is decremented again an
contents of the low-order register (C, E, L, flag
copied to that location.
Example − PUSH K

The contents of the memory location pointed out


stack pointer register are copied to the low-order re
(C, E, L, status flags) of the operand.
Pop off stack to the The stack pointer is incremented by 1 and the conte
POP Reg. pair
register pair that memory location are copied to the high-order r
(B, D, H, A) of the operand.
The stack pointer register is again incremented by 1.
Example − POPK

Output the data from the The contents of the accumulator are copied into th
OUT 8-bit port address accumulator to a port port specified by the operand.
with 8bit address Example − OUT K9L

IN 8-bit port address Input data to The contents of the input port designated in the opera
accumulator from a port read and loaded into the accumulator.
with 8-bit address Example − IN5KL
Opcod
Operand Meaning Explanation
e

The contents of the register or memory are added to


Add register or
R the contents of the accumulator and the result is
ADD memory, to the
M stored in the accumulator.
accumulator
Example − ADD K.

The contents of the register or memory & M the


Carry flag are added to the contents of the
R Add register to the
ADC accumulator and the result is stored in the
M accumulator with carry
accumulator.
Example − ADC K

The 8-bit data is added to the contents of the


Add the immediate to accumulator and the result is stored in the
ADI 8-bit data
the accumulator accumulator.
Example − ADI 55K

The 8-bit data and the Carry flag are added to the
Add the immediate to
contents of the accumulator and the result is stored
ACI 8-bit data the accumulator with
in the accumulator.
carry
Example − ACI 55K

The instruction stores 16-bit data into the register


Load the register pair
LXI Reg. pair, 16bit data pair designated in the operand.
immediate
Example − LXI K, 3025M

The 16-bit data of the specified register pair are


Add the register pair to
DAD Reg. pair added to the contents of the HL register.
H and L registers
Example − DAD K

The contents of the register or the memory are


Subtract the register or
R subtracted from the contents of the accumulator, and
SUB the memory from the
M the result is stored in the accumulator.
accumulator
Example − SUB K

The contents of the register or the memory & M the


Subtract the source and Borrow flag are subtracted from the contents of the
R
SBB borrow from the accumulator and the result is placed in the
M
accumulator accumulator.
Example − SBB K

The 8-bit data is subtracted from the contents of the


Subtract the immediate accumulator & the result is stored in the
SUI 8-bit data
from the accumulator accumulator.
Example − SUI 55K

The contents of register H are exchanged with the


Exchange H and L with contents of register D, and the contents of register L
XCHG None
D and E are exchanged with the contents of register E.
Example − XCHG

The contents of the designated register or the


R Increment the register memory are incremented by 1 and their result is
INR
M or the memory by 1 stored at the same place.
Example − INR K

The contents of the designated register pair are


Increment register pair incremented by 1 and their result is stored at the
INX R
by 1 same place.
Arithmetic instructions in 8085 microprocessor
Arithmetic Instructions are the instructions which perform basic arithmetic operations such as
addition, subtraction and a few more. In 8085 microprocessor, the destination operand is
generally the accumulator.

Following is the table showing the list of Arithmetic instructions with their meanings.

1 Add) – The content of operand are added to the content of the accumulator and the result is
stored in accumulator .
with the addition instruction , the following 3 operations can be done.
1) any 8 bit number can be added to the contents of the accumulator and the result is stored in
the accumulator.
2) The contents of a register can be added to the contents of the accumulator and result is
stored in the accumulator .
3) The contents of a memory location can be added to the contents of the accumulator and
result is stored in accumulator.
this 1 byte instruction.
example – addb c it adds the content of accumulator to the content of the register b
2) SUB Any 8 bit data or the contents of a register or contents of a memory location can be
subtracted from the contents of the accumulator.
with the subtraction instruction the following 3 operator can be done .
1) any 8 bit number can be subtracted from the contents of the accumulator . The result is
stored in the accumulator.
In the table, R stands for register M stands for memory Mc stands for memory contents r.p.
stands for register pair

Applications:

Data processing: The arithmetic instructions in the 8085 microprocessor are used to perform
mathematical operations on data stored in memory or registers. This allows the
microprocessor to manipulate and process data in various ways, such as performing
calculations, generating checksums, and processing sensor data.
Control systems: The arithmetic instructions are used to perform complex calculations in
control systems. These calculations are used to make decisions based on sensor data and
other inputs, and to generate control signals that regulate the behavior of the system.
Signal processing: The arithmetic instructions in the 8085 microprocessor are used in digital
signal processing applications, such as audio and image processing. These instructions are
used to perform various operations on the digital signal data, such as filtering, compression,
and encryption.
Communication systems: The arithmetic instructions are used to perform various operations
in communication systems, such as signal modulation and demodulation, error correction,
and encryption/decryption.
Gaming: The arithmetic instructions are used to perform various operations in gaming
applications, such as calculating the trajectory of projectiles, simulating physics, and
rendering graphics.

Advantages:

Efficient arithmetic operations: The arithmetic instructions in the 8085 microprocessor can
perform a variety of arithmetic and logical operations quickly and efficiently, making it
suitable for applications that require fast arithmetic operations.
Reduced memory access: The use of registers and the accumulator in the 8085
microprocessor can help reduce the number of memory accesses required during arithmetic
operations, which can improve the overall performance of the system.
Supports a wide range of operations: The arithmetic instructions in the 8085
microprocessor support a wide range of operations, including addition, subtraction, logical
AND/OR/XOR, and shifting/rotating operations.
Simplifies programming: The arithmetic instructions in the 8085 microprocessor simplify
programming by providing a set of dedicated instructions for performing arithmetic and
logical operations.

Disadvantages:

Limited precision: The 8085 microprocessor uses 8-bit registers and arithmetic operations,
which limits the precision of calculations that can be performed. This can be a disadvantage
for applications that require high precision arithmetic.
Limited range of operations: Although the 8085 microprocessor supports a wide range of
arithmetic and logical operations, it does not support advanced operations such as
trigonometric functions or complex numbers.
Limited memory access: Although the use of registers can reduce the number of memory
accesses required, the limited number of registers in the 8085 microprocessor can restrict the
amount of data that can be manipulated at any given time.
Complex addressing modes: The addressing modes used in the arithmetic instructions can
be complex, which can make programming more difficult.

tions on data in registers and memory. Logical operations are operations that manipulate the
bits of data without affecting their numerical value. These operations include AND, OR,
XOR, and NOT.
The logical instructions in the 8085 microprocessor include:
1. ANA – Logical AND: This instruction performs a logical AND operation between the
accumulator and a specified register or memory location, and stores the result in the
accumulator. For example, the instruction “ANA B” performs a logical AND operation
between the contents of the accumulator and the contents of the B register.
2. ORA – Logical OR: This instruction performs a logical OR operation between the
accumulator and a specified register or memory location, and stores the result in the
accumulator. For example, the instruction “ORA C” performs a logical OR operation
between the contents of the accumulator and the contents of the C register.
3. XRA – Logical XOR: This instruction performs a logical XOR operation between the
accumulator and a specified register or memory location, and stores the result in the
accumulator. For example, the instruction “XRA M” performs a logical XOR operation
between the contents of the accumulator and the contents of the memory location
pointed to by the HL register.
4. CPL – Logical Complement: This instruction performs a logical complement operation
on the contents of the accumulator. This operation flips all the bits of the accumulator,
effectively reversing its value.
5. CMA – Complement Accumulator: This instruction performs a bitwise complement
operation on the contents of the accumulator. This operation flips all the bits of the
accumulator, effectively reversing its value.
Logical instructions are the instructions that perform basic logical operations such as AND,
OR, etc. In the 8085 microprocessor, the destination operand is always the accumulator.
Here logical operation works on a bitwise level.

Why use Logical instructions in 8085 microprocessor ?


Here are some specific reasons why logical instructions are used in the 8085
microprocessor:
1. Data comparison: Logical instructions can be used to compare two pieces of data bit-
by-bit. For example, the XOR instruction can be used to compare the contents of two
registers or memory locations and set a flag if they are not equal.
2. Data masking: Logical instructions can be used to selectively mask or extract specific
bits of data. For example, the AND instruction can be used to mask off all but a specific
set of bits, while the OR instruction can be used to set specific bits to 1.
3. Data encryption: Logical instructions can be used to perform bitwise encryption of data.
By performing a logical XOR between the data and a secret key, the data can be
encrypted in a reversible way that can only be decrypted with the same key.
4. Decision-making: Logical instructions can be used to make decisions in programs. For
example, the AND instruction can be used to test if multiple conditions are true, while
the OR instruction can be used to test if at least one condition is true.
Following is the table showing the list of logical instructions:

OPCODE OPERAND DESTINATION EXAMPLE

ANA R A = A AND R ANA B

ANA
ANA M A = A AND Mc
2050

ANI 8-bit data A = A AND 8-bit data ANI 50

ORA R A = A OR R ORA B

ORA M A = A OR Mc ORA
OPCODE OPERAND DESTINATION EXAMPLE

2050

ORI 8-bit data A = A OR 8-bit data ORI 50

XRA R A = A XOR R XRA B

XRA
XRA M A = A XOR Mc
2050

XRI 8-bit data A = A XOR 8-bit data XRI 50

CMA none A = 1’s complement of A CMA

CMP R Compares R with A and triggers the flag register CMP B

Compares Mc with A and triggers the flag CMP


CMP M
register 2050

Compares 8-bit data with A and triggers the flag


CPI 8-bit data CPI 50
register

RRC none Rotate accumulator right without carry RRC

RLC none Rotate accumulator left without carry RLC

RAR none Rotate accumulator right with carry RAR

RAL none Rotate accumulator left with carry RAR

CMC none Compliments the carry flag CMC

STC none Sets the carry flag STC

In the table,
R stands for register
M stands for memory
Mc stands for memory contents

Applications :
Data processing: The logical instructions in the 8085 microprocessor are used to
manipulate and process data stored in memory or registers. These instructions are used to
perform various logical operations, such as AND, OR, XOR, and complement, which are
used to filter, mask, and manipulate data in various ways.
Control systems: The logical instructions are used in control systems to perform logical
operations on sensor data and other inputs. These operations are used to generate control
signals that regulate the behavior of the system.
Signal processing: The logical instructions in the 8085 microprocessor are used in digital
signal processing applications, such as audio and image processing. These instructions are
used to perform various logical operations on the digital signal data, such as masking,
filtering, and thresholding.
Communication systems: The logical instructions are used in communication systems to
perform logical operations on data, such as error detection and correction, and
encryption/decryption.
Gaming: The logical instructions are used in gaming applications to perform logical
operations on game data, such as collision detection, pathfinding.

Advantages:

1. Efficient logical operations: The logical instructions in the 8085 microprocessor can
perform logical operations quickly and efficiently, making it suitable for applications
that require fast logical operations.
2. Reduced memory access: The use of registers and the accumulator in the 8085
microprocessor can help reduce the number of memory accesses required during logical
operations, which can improve the overall performance of the system.
3. Simplifies programming: The logical instructions in the 8085 microprocessor simplify
programming by providing a set of dedicated instructions for performing logical
operations.
4. Supports a wide range of operations: The logical instructions in the 8085
microprocessor support a wide range of operations, including AND, OR, XOR, and
complement operations.

Disadvantages:

1. Limited precision: The 8085 microprocessor uses 8-bit registers and logical
operations, which limits the precision of calculations that can be performed. This can be
a disadvantage for applications that require high precision logical operations.
2. Limited range of operations: Although the 8085 microprocessor supports a wide range
of logical operations, it does not support advanced operations such as trigonometric
functions or complex numbers.
3. Limited memory access: Although the use of registers can reduce the number of
memory accesses required, the limited number of registers in the 8085 microprocessor
can restrict the amount of data that can be manipulated at any given time.
4. Complex addressing modes: The addressing modes used in the logical instructions can
be complex, which can make programming more difficult.
Read related post: Arithmetic instructions in 8085 microprocessor
Branching instructions in 8085 microprocessor
Last Updated : 07 May, 2023



Branching instructions refer to the act of switching execution to a different instruction


sequence as a result of executing a branch instruction.
The three types of branching instructions are:

1. Jump (unconditional and conditional)

2. Call (unconditional and conditional)

3. Return (unconditional and conditional)

1. Jump Instructions – The jump instruction transfers the program sequence to the
memory address given in the operand based on the specified flag. Jump instructions are 2
types: Unconditional Jump Instructions and Conditional Jump Instructions.
(a) Unconditional Jump Instructions: Transfers the program sequence to the described
memory address.

OPCOD
E OPERAND EXPLANATION EXAMPLE

JMP address Jumps to the address JMP 2050

(b) Conditional Jump Instructions: Transfers the program sequence to the described
memory address only if the condition in satisfied.

OPCOD
E OPERAND EXPLANATION EXAMPLE

JC address Jumps to the address if carry flag is 1 JC 2050

JNC address Jumps to the address if carry flag is 0 JNC 2050

JZ address Jumps to the address if zero flag is 1 JZ 2050

JNZ address Jumps to the address if zero flag is 0 JNZ 2050

JPE address Jumps to the address if parity flag is 1 JPE 2050


OPCOD
E OPERAND EXPLANATION EXAMPLE

JPO address Jumps to the address if parity flag is 0 JPO 2050

JM address Jumps to the address if sign flag is 1 JM 2050

JP address Jumps to the address if sign flag 0 JP 2050

2. Call Instructions – The call instruction transfers the program sequence to the memory
address given in the operand. Before transferring, the address of the next instruction after
CALL is pushed onto the stack. Call instructions are 2 types: Unconditional Call
Instructions and Conditional Call Instructions.
(a) Unconditional Call Instructions: It transfers the program sequence to the memory
address given in the operand.

OPCOD
E OPERAND EXPLANATION EXAMPLE

Unconditionally
CALL address CALL 2050
calls

(b) Conditional Call Instructions: Only if the condition is satisfied, the instructions
executes.
OPCOD
E OPERAND EXPLANATION EXAMPLE

CC address Call if carry flag is 1 CC 2050

CNC address Call if carry flag is 0 CNC 2050

CZ address Calls if zero flag is 1 CZ 2050

CNZ address Calls if zero flag is 0 CNZ 2050

CPE address Calls if parity flag is 1 CPE 2050

CPO address Calls if parity flag is 0 CPO 2050

CM address Calls if sign flag is 1 CM 2050

CP address Calls if sign flag is 0 CP 2050


3. Return Instructions – The return instruction transfers the program sequence from the
subroutine to the calling program. Return instructions are 2 types: Unconditional Jump
Instructions and Conditional Jump Instructions.

(a) Unconditional Return Instruction: The program sequence is transferred


unconditionally from the subroutine to the calling program.

OPCODE OPERAND EXPLANATION EXAMPLE

Return from the subroutine


RET none RET
unconditionally

(b) Conditional Return Instruction: The program sequence is transferred unconditionally


from the subroutine to the calling program only is the condition is satisfied.
OPCODE OPERAND EXPLANATION EXAMPLE

RC none Return from the subroutine if carry flag is 1 RC

RNC none Return from the subroutine if carry flag is 0 RNC

RZ none Return from the subroutine if zero flag is 1 RZ

RNZ none Return from the subroutine if zero flag is 0 RNZ

Return from the subroutine if parity flag is


RPE none RPE
1

Return from the subroutine if parity flag is


RPO none RPO
0

RM none Returns from the subroutine if sign flag is 1 RM

RP none Returns from the subroutine if sign flag is 0 RP

Advantages:

Enables conditional execution: The branching instructions in the 8085 microprocessor


allow for conditional execution of code, which can help optimize program flow and
improve overall efficiency.
Simplifies programming: The branching instructions in the 8085 microprocessor simplify
programming by providing a set of dedicated instructions for branching to different
memory locations based on conditions.
Supports a wide range of operations: The branching instructions in the 8085
microprocessor support a wide range of operations, including conditional branching,
unconditional branching, and subroutine calls.
Allows for loop execution: The branching instructions in the 8085 microprocessor can be
used to implement loops by branching to a memory location that contains a loop
instruction.

Disadvantages:

Limited branching range: The 8085 microprocessor has a limited branching range, which
can restrict the amount of memory that can be accessed. This can be a disadvantage for
applications that require a large number of branching instructions.
Limited number of condition codes: The 8085 microprocessor has a limited number of
condition codes, which can restrict the types of conditions that can be tested.
Complex addressing modes: The addressing modes used in the branching instructions can
be complex, which can make programming more difficult.
Limited instruction set: The 8085 microprocessor has a limited instruction set, which can
limit the types of branching instructions that can be used. This can be a disadvantage for
applications that require complex program flow.

Applications :

Looping: Branching instructions such as JMP, JZ, JNZ, JC, and JNC are used to implement
loops in programs. This allows the program to repeat a set of instructions until a specific
condition is met.
Decision-making: Conditional branching instructions are used to implement decision-
making in programs. This allows the program to make decisions based on the current state
of the microprocessor and branch to different parts of the program accordingly.
Subroutine calls: Call instructions, such as CALL and RET, are used to call subroutines in
programs. This allows the program to reuse code and execute common tasks in a modular
manner.
Interrupt handling: Branching instructions are used in interrupt handling to transfer
control to an interrupt service routine. This involves branching to a different part of the
program to handle the interrupt, and then returning to the main program after the interrupt
is serviced.
Program flow control: Branching instructions are used to control the flow of programs by
transferring control to different parts of the program based on specific conditions or events.
This allows the program to execute specific tasks at specific times and in a specific order.

You might also like