8085 Instruction Set (Part 1): Data Transfer, Arithmetic, and Logical Instructions with Examples - 2.2 | Module 2: Microprocessor Architectures: 8085 and 8086 | Microcontroller
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

Interactive Audio Lesson

Listen to a student-teacher conversation explaining the topic in a relatable way.

Data Transfer Instructions

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we're going to start with data transfer instructions. Can anyone explain what we mean by 'data transfer' in terms of the 8085 microprocessor?

Student 1
Student 1

I think it has to do with how data is moved around in the registers and memory.

Teacher
Teacher

Exactly! Data transfer instructions are aimed at copying data without altering any flags. For example, the `MOV` command allows us to transfer data from one register to another. Can anyone provide an example of a `MOV` command?

Student 2
Student 2

Like `MOV A, B`, where the content of register B is copied to register A?

Teacher
Teacher

That's correct! If register B contains 35H, what will happen to register A after executing `MOV A, B`?

Student 3
Student 3

Register A will also contain 35H after that operation.

Teacher
Teacher

Perfect! We also have `MVI` for moving immediate data, such as `MVI C, 50H` which puts 50H directly into register C. What about moving data to and from memory?

Student 4
Student 4

That would involve `MOV R, M` or `MOV M, R` to transfer between registers and memory using the H-L pair!

Teacher
Teacher

Exactly! So remember the acronym *MRM* for 'Memory to Register' and 'Register to Memory' to help you recall those operations.

Teacher
Teacher

Let's summarize today’s key points: Data transfer instructions are foundational in the 8085, allowing movement of data between registers and memory without affecting flags.

Arithmetic Instructions

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Next, let's delve into arithmetic instructions. What operations do you think these handle?

Student 1
Student 1

Basic math operations like addition, subtraction, and maybe incrementing or decrementing values?

Teacher
Teacher

Correct! For example, after executing `ADD B`, if A is 10H and B is 05H, what will A be?

Student 2
Student 2

A will be 15H after the addition!

Teacher
Teacher

Yes! And when performing subtraction with `SUB B`, what happens to the flags?

Student 3
Student 3

The Zero, Sign, Parity, and Carry flags can be affected based on the result of A - B.

Teacher
Teacher

Exactly! Remember, *Flags Are Affected* when it comes to arithmetics! And let's discuss increments and decrements. Can anyone tell me the command?

Student 4
Student 4

It's `INR` to increment and `DCR` to decrement.

Teacher
Teacher

Well done! Let's recap what we learned about arithmetic instructions: they perform basic operations and affect flags based on outcomes.

Logical Instructions

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Finally, let's explore logical instructions. What are these used for in programming?

Student 1
Student 1

They're used for bitwise operations, like AND, OR, and comparisons!

Teacher
Teacher

Exactly! For example, with `ANA B`, if A is 0F0H and B is 0F0H, what will be the value of A?

Student 2
Student 2

A will become 00H after the AND operation.

Teacher
Teacher

Correct! And how does `CMP R` work?

Student 3
Student 3

It compares the value in register R with A and sets the flags accordingly without changing A.

Teacher
Teacher

Great summary, *Compare A with R*, makes it easier to remember! Logical operations are vital for decision-making in programs. To wrap up, we discussed how logical instructions perform bitwise operations and can set flags according to results.

Introduction & Overview

Read a summary of the section's main ideas. Choose from Basic, Medium, or Detailed.

Quick Overview

This section outlines the 8085 instruction set, focusing on data transfer, arithmetic, and logical operations with relevant examples.

Standard

The 8085 instruction set is crucial for data manipulation, comprising data transfer instructions that facilitate moving data between registers and memory, arithmetic instructions for calculations, and logical instructions that perform bitwise operations. Various examples illustrate each instruction's functionality.

Detailed

8085 Instruction Set Overview

The Intel 8085 microprocessor's instruction set is essential for performing operations on data and communicates commands to the CPU. This section introduces three primary categories of instructions: Data Transfer Instructions, Arithmetic Instructions, and Logical Instructions.

Key Points Covered:

  1. Data Transfer Instructions: These instructions enable copying data between registers, memory, and immediate values. They include operations such as MOV (moving data between registers), MVI (moving immediate data to registers), LDA/STA (loading/storing data to/from memory), and several others.
  2. Arithmetic Instructions: This category encompasses commands for performing arithmetic operations, including addition (ADD), subtraction (SUB), increment (INR), decrement (DCR), and double addition (DAD). Each operation affects specific flags in the flag register based on the result of the operation.
  3. Logical Instructions: Logical operations applied to data are handled through instructions like AND (ANA), OR (ORA), XOR (XRA), and comparisons (CMP). These operations also modify specific flags based on their outcomes.

Understanding these instruction categories is pivotal for effective programming in 8085 assembly language, as they facilitate crucial data manipulation needed in a variety of applications.

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Instruction Set Overview

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

The 8085 instruction set is a collection of commands that the microprocessor understands. These instructions are represented by opcodes and operands, which the CPU decodes and executes. The instructions are broadly categorized based on their function.
Instruction Format: MNEMONIC Operand1, Operand2 (Operand order can vary).

Detailed Explanation

The 8085 microprocessor operates based on a predefined set of instructions known as its instruction set. Each instruction consists of an opcode, which is a representation of the command, and one or more operands, which are the data or locations on which the instruction operates. The format can vary, but typically it follows the structure of a 'MNEMONIC' followed by operands. Understanding this format is crucial for writing and interpreting assembly language programs as it standardizes how commands are executed.

Examples & Analogies

Think of the instruction set as a recipe book. Each recipe (instruction) has a title (opcode) and a list of ingredients (operands). Just like you follow a recipe to create a dish, the microprocessor follows the instruction set to perform tasks.

Data Transfer Instructions

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Data Transfer Instructions (Copy Operations): These instructions copy data between registers, between a register and memory, or between an immediate value and a register/memory. They do not affect any flags.

Register to Register Transfer:

  • MOV Rd, Rs: Copy the content of source register Rs to destination register Rd.
  • Rd can be A, B, C, D, E, H, L.
  • Rs can be A, B, C, D, E, H, L.
  • Numerical Example: If register B contains 35H, after MOV A, B, register A will contain 35H. (B remains 35H).

Memory to Register / Register to Memory Transfer:

  • MOV R, M: Copy the content of memory location pointed by H-L pair to register R.
  • MOV M, R: Copy the content of register R to memory location pointed by H-L pair.
  • Numerical Example: If H-L pair contains 2000H and memory location 2000H contains AAH, after MOV B, M, register B will contain AAH.

Immediate Data to Register / Memory:

  • MVI R, Data: Move immediate 8-bit Data to register R.
  • Numerical Example: MVI C, 50H. Register C will contain 50H.
  • MVI M, Data: Move immediate 8-bit Data to memory location pointed by H-L pair.
  • Numerical Example: If H-L pair contains 3000H, after MVI M, 7BH, memory location 3000H will contain 7BH.

Load/Store Accumulator Direct:

  • LDA Adr: Load Accumulator with the content of the memory location specified by the 16-bit address Adr.
  • Numerical Example: If memory location 1000H contains F0H, after LDA 1000H, Accumulator A will contain F0H.
  • STA Adr: Store content of Accumulator into the memory location specified by the 16-bit address Adr.

Load/Store H-L Pair Direct:

  • LHLD Adr: Load H-L pair with content of Adr and Adr+1.
  • Numerical Example: If memory location 2000H contains 12H and 2001H contains 34H, after LHLD 2000H, L will be 12H and H will be 34H. So HL pair will be 3412H.
  • SHLD Adr: Store H-L pair content into Adr and Adr+1. Content of L goes to Adr, and H goes to Adr+1.

Detailed Explanation

Data Transfer Instructions in the 8085 instruction set are designed for moving data around without affecting the processor's state or the flags. These include moving data between registers, moving data to and from memory, and loading immediate values into registers. Understanding these operations is essential because data transfer is fundamental to processing, computation, and the overall functioning of programs in assembly language. Each operation has specific syntax and semantics, including how registers and memory locations are specified.

Examples & Analogies

Imagine you are organizing a library. Moving books (data) from one shelf (register) to another or from a box (memory) to a shelf is akin to executing data transfer instructions. Each movement does not change the books but simply repositions them for easier access.

Arithmetic Instructions

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Arithmetic Instructions: These instructions perform addition, subtraction, increment, and decrement operations. They affect the flags (S, Z, AC, P, CY) based on the result.

Addition:

  • ADD R: Add content of register R to Accumulator. Result in A.
  • Numerical Example: If A=10H, B=05H, after ADD B, A will be 15H.
  • Flags: Z=0, P=1 (even parity for 15H=00010101B), CY=0, AC=0, S=0.
  • ADD M: Add content of memory pointed by H-L to Accumulator. Result in A.
  • ADI Data: Add immediate 8-bit Data to Accumulator. Result in A.

Subtraction:

  • SUB R: Subtract content of register R from Accumulator. Result in A. (A = A - R).
  • Numerical Example: If A=10H, B=05H, after SUB B, A will be 0BH.
  • Flags: Z=0, P=1 (even parity for 0BH=00001011B), CY=0 (no borrow), AC=0, S=0.
  • SUB M: Subtract content of memory pointed by H-L from Accumulator.

Increment/Decrement:

  • INR R: Increment content of register R by 1. (Affects all flags except CY).
  • Numerical Example: If B=0FH, after INR B, B will be 10H.
  • DCR R: Decrement content of register R by 1. (Affects all flags except CY).

Detailed Explanation

Arithmetic Instructions are crucial for performing mathematical operations within the CPU. These instructions allow the 8085 to execute basic arithmetic tasks like addition and subtraction, as well as modifying values via incrementing or decrementing. These operations not only yield new results but also affect the status flags, indicating conditions like zero results or overflows. Understanding these is essential for effective programming in assembly language, as you often need to manipulate values mathematically.

Examples & Analogies

Think of a calculator. When you add, subtract, increment, or decrement numbers, you are performing arithmetic operations. The calculator also shows indicators for situations like whether the result is zero or if it exceeded a particular limit, much like how processors use flags to indicate the result conditions.

Logical Instructions

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

Logical Instructions: These instructions perform bitwise logical operations (AND, OR, XOR, NOT) on operands. They affect S, Z, P, CY, AC flags. CY is always reset to 0; AC is affected according to the operation.

Logical AND:

  • ANA R: Logical AND content of register R with Accumulator. Result in A.
  • Numerical Example: A=0F0H (11110000B), B=0F0H (00001111B). After ANA B, A will be 00H. CY=0.
  • ANA M: Logical AND content of memory pointed by H-L with Accumulator.

Logical OR:

  • ORA R: Logical OR content of register R with Accumulator. Result in A.
  • Numerical Example: A=0F0H (11110000B), B=0F0H (00001111B). After ORA B, A will be 0FFH. CY=0.

Logical XOR:

  • XRA R: Logical XOR content of register R with Accumulator. Result in A.
  • Numerical Example: A=0F0H (11110000B), B=0F0H (00001111B). After XRA B, A will be 0F0H XOR 00001111B = 11111111B (FFH). CY=0.

Detailed Explanation

Logical Instructions enable bitwise operations on values, facilitating tasks like setting, clearing, or toggling bits. Each operation applies specific logical rules (AND, OR, and XOR) that produce a result depending on the input values. Understanding how these instructions manipulate bits is vital for operations such as masking bits, which can control individual bits in a byte to represent various states in programming.

Examples & Analogies

Consider a light switch. Using logical operations can be compared to having multiple switches controlling the same light in a room. AND can be seen as needing all switches to be ON for the light to be lit, while OR would mean that at least one switch must be ON. XOR represents toggling: when one switch is ON and another is OFF, the light is ON; but if both are ON or both are OFF, the light remains OFF.

Definitions & Key Concepts

Learn essential terms and foundational ideas that form the basis of the topic.

Key Concepts

  • Data Transfer Instructions: Instructions moving data between registers/memory.

  • Arithmetic Instructions: Instructions for mathematical operations, affecting flags.

  • Logical Instructions: Instructions for bitwise operations, modifying status flags.

Examples & Real-Life Applications

See how the concepts apply in real-world scenarios to understand their practical implications.

Examples

  • Example for MOV: MOV A, B where contents of B are copied into A.

  • Example for ADD: ADD B adds the value of B to A, modifying flags accordingly.

  • Example for ANA: ANA B performs bitwise AND of A and B.

Memory Aids

Use mnemonics, acronyms, or visual cues to help remember key information more easily.

🎵 Rhymes Time

  • To move data is plain to see, use MOV A and let it be!

📖 Fascinating Stories

  • Imagine a postman moving letters (data), he picks up A from his bag and drops it into B – that's MOV for you!

🧠 Other Memory Gems

  • Remember 'A for Add, S for Subtract' to recall arithmetic instruction types.

🎯 Super Acronyms

DREAM - Data transfer, Register storage, Execute arithmetic, Modify logical operations!

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: MOV

    Definition:

    An instruction that copies data from one register to another without altering any flags.

  • Term: MVI

    Definition:

    An instruction that moves immediate data directly into a register.

  • Term: ADD

    Definition:

    An instruction that adds the content of a register to the Accumulator, modifying flags based on the result.

  • Term: SUB

    Definition:

    An instruction that subtracts the content of a register from the Accumulator, affecting various flags.

  • Term: ANA

    Definition:

    An instruction that performs a logical AND operation between the Accumulator and a register.

  • Term: CMP

    Definition:

    An instruction that compares the contents of a register with the Accumulator, setting flags based on the outcome.