Arithmetic Instructions - 1.3.2 | EXPERIMENT NO. 1:Introduction to 8085 Microprocessor - Architecture and Basic Operations | Microcontroller Lab
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.

Basic Arithmetic Operations

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Today, we will start with one of the fundamental arithmetic instructions: ADD. Can anyone tell me what this instruction does?

Student 1
Student 1

ADD adds the contents of a register to the Accumulator, right?

Teacher
Teacher

Exactly! The result stays in the Accumulator. For example, if we have A = 10H and we add B = 05H, what will be the new value of A?

Student 2
Student 2

It will be 15H!

Teacher
Teacher

Perfect! And let's remember, the flags will be updated as well. The Sign flag will tell us if the result is negative, while the Zero flag tells us if the result is zero. Does anyone remember what happens to the Carry flag in this case?

Student 3
Student 3

The Carry flag will be set to 0 since there's no overflow.

Teacher
Teacher

Correct! It's essential to know how these flags affect subsequent operations. Let’s recap: ADD adds a register to the Accumulator, and the flags update accordingly.

Immediate Addition

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Now moving on to another instruction – ADI. Who can tell me what this does?

Student 2
Student 2

ADI adds immediate data directly to the Accumulator.

Teacher
Teacher

Exactly! For instance, if A = F0H and we perform ADI 20H, what would be the new value?

Student 4
Student 4

It would be 10H because of the overflow!

Teacher
Teacher

Right! And what about the flags after this operation?

Student 1
Student 1

The Carry flag would be set because there's an overflow!

Teacher
Teacher

Exactly! So ADI is crucial for immediate arithmetic operations and can lead to important flag updates.

Subtraction Instructions

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Next up, let's talk about subtraction. How does the SUB instruction differ from ADD?

Student 3
Student 3

SUB takes a register’s content away from the Accumulator.

Teacher
Teacher

That’s correct! What happens if we try to subtract a larger number, like 10H from 05H?

Student 4
Student 4

It will set the Carry flag since we're going below zero.

Teacher
Teacher

Exactly! The result in the Accumulator will be in two’s complement format. And what about SUI?

Student 1
Student 1

SUI works like SUB, but with an immediate value, right?

Teacher
Teacher

Yes! That’s the way to think about it. Always remember how these operations affect your flags.

Increment and Decrement Instructions

Unlock Audio Lesson

Signup and Enroll to the course for listening the Audio Lesson

0:00
Teacher
Teacher

Finally, let's cover the INR and DCR instructions. What do these do?

Student 2
Student 2

INR increments a register or memory location by 1, and DCR decrements it.

Teacher
Teacher

Correct! What flags might change after these operations?

Student 3
Student 3

The Zero flag could change if the result becomes zero, and the Sign flag may change if it goes negative.

Teacher
Teacher

Exactly! That's an important aspect to consider. And don’t forget about the Auxiliary Carry flag as well.

Student 4
Student 4

Why is AC important?

Teacher
Teacher

Good question! It’s primarily used when handling BCD numbers. In summary, understand how all the arithmetic instructions impact both the Accumulator and the flags.

Introduction & Overview

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

Quick Overview

Arithmetic instructions in the 8085 microprocessor are vital for performing basic mathematical operations that impact the status flags.

Standard

This section details the fundamental arithmetic instructions available in the 8085 microprocessor, including addition, subtraction, increment, and decrement operations, along with their effect on the Accumulator and status flags. Understanding these instructions is essential for effective programming and operation of microprocessors.

Detailed

Detailed Summary

In this section, we dive into the arithmetic instructions of the 8085 microprocessor, which are essential for performing basic mathematical operations fundamental to computing tasks. The 8085 features a variety of instructions to perform arithmetic operations that include:

  • ADD: This instruction adds the content of a specified register to the Accumulator and stores the result back in the Accumulator. The status flags reflect the result of the operation.
  • ADI: Similar to ADD, but this adds an immediate 8-bit data value directly to the Accumulator.
  • SUB: This instruction subtracts the content of a specified register from the Accumulator, also updating the flags accordingly.
  • SUI: In this case, immediate data is subtracted from the Accumulator.
  • INR: Used to increment the content of a specified register or memory location by one, affecting the Zero and Sign flags.
  • DCR: It decrements the content of a specified register or memory location by one, impacting the status flags similarly.

Each arithmetic operation is significant as it influences the status flags - Sign (S), Zero (Z), Auxiliary Carry (AC), Parity (P), and Carry (C) - which are crucial for decision-making and control in programs.

Audio Book

Dive deep into the subject with an immersive audiobook experience.

Introduction to Arithmetic Instructions

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

These instructions perform basic arithmetic operations (addition, subtraction, increment, decrement) and significantly affect the status flags.

Detailed Explanation

This chunk introduces arithmetic instructions in the 8085 microprocessor. It states that these instructions are used for fundamental arithmetic operations such as adding or subtracting values. Importantly, the outcome of these operations can influence the status flags, which are indicators of the operation's results and conditions in the CPU.

Examples & Analogies

Think of the arithmetic instructions as the basic math functions you learn in school. Just as adding or subtracting numbers gives you different results—and might make you realize you spent too much money or added up your scores wrong—arithmetic instructions in a microprocessor perform similar calculations and keep track of whether you hit zero, overflowed, or had a deficit (borrow).

ADD Instruction

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

● ADD (Add Register to Accumulator): Adds the content of a specified register to the Accumulator. The result is stored in the Accumulator.

○ ADD R: A = A + R.

■ Example: ADD B (A = A + B).

■ Numerical Example:
Initial: A = 10H, B = 05H
Instruction: ADD B
Result: A = 15H. Flags: S=0, Z=0, AC=0, P=1, C=0.

Detailed Explanation

The ADD instruction is used to add the contents of a register (like B or C) to the Accumulator (A). After performing the addition, the value of the result is stored back in the Accumulator. This operation affects several flags that indicate the result's nature, such as whether the result is zero or if there was a carry. An example shows how adding 05H from register B to 10H in the Accumulator results in 15H, while the flags change based on this operation.

Examples & Analogies

Imagine you're keeping score during a game. Every time you score extra points (like getting extra goals), you add those points to your total score. If you record your score on a scoreboard (like the Accumulator), the scoreboard updates with each new total. If you reach a certain number (like zero or a total that overflows a typical limit), you note it (like the flags getting updated) to keep track of whether you should reset your score or carry over to a new tally.

ADI Instruction

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

● ADI (Add Immediate to Accumulator): Adds immediate 8-bit data to the Accumulator. The result is stored in the Accumulator.

○ ADI Data: A = A + Data.

■ Example: ADI 0FH (A = A + 0FH).

■ Numerical Example (with Carry):
Initial: A = F0H, B = 20H
Instruction: ADI 20H (Assuming we use ADI directly here for simplicity, though the example implies ADD B from prev.)
Calculation: F0H (240) + 20H (32) = 110H (272).
Result: A = 10H (lower 8 bits). Flags: S=0, Z=0, AC=0, P=1, C=1. (Carry flag set due to overflow).

Detailed Explanation

The ADI instruction allows the microprocessor to add an immediate value directly to the Accumulator. This immediate value is part of the instruction. Like the ADD instruction, the result affects the flags too. When the operation results in a value that exceeds what can be represented with 8 bits, the Carry flag is set. The example illustrates adding 20H to F0H, resulting in a value of 10H, which shows how the overflow from the addition sets the flag.

Examples & Analogies

Think of ADI as a quick addition you do in your head when someone gives you cash, for instance, as a tip. Every time you receive cash, you add it to your wallet (the Accumulator). If your wallet goes over a certain limit (like overflowing your pocket), you remember that you went overboard (setting the flag) which alerts you to put some back!

SUB Instruction

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

● SUB (Subtract Register from Accumulator): Subtracts the content of a specified register from the Accumulator. The result is stored in the Accumulator.

○ SUB R: A = A - R.

■ Example: SUB C (A = A - C).

■ Numerical Example (with Borrow):
Initial: A = 05H, C = 10H
Instruction: SUB C
Calculation: 05H - 10H. In 8-bit 2's complement, this becomes 05H + (2's complement of 10H) = 05H + F0H = F5H.
Result: A = F5H. Flags: S=1, Z=0, AC=0, P=0, C=1. (Carry flag set, indicating a borrow).

Detailed Explanation

The SUB instruction subtracts the value of a register from the Accumulator. The difference is kept in the Accumulator, and again several flags will show the outcome. If the result becomes negative, a borrow flag is set. The example here showcases subtracting a larger number (10H) from a smaller one (05H), yielding a negative result, hence setting the flags appropriately.

Examples & Analogies

Consider subtracting money from your savings: if you have $5 and spend $10, you're in a deficit. Your bank balance doesn’t just show negative numbers; it also alerts you that you 'borrowed' that amount, which is similar to how the carry flag is set to notify you that subtraction has gone beyond zero.

SUI Instruction

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

● SUI (Subtract Immediate from Accumulator): Subtracts immediate 8-bit data from the Accumulator. The result is stored in the Accumulator.

○ SUI Data: A = A - Data.

■ Example: SUI 08H (A = A - 08H).

Detailed Explanation

The SUI instruction subtracts a direct immediate value from the Accumulator in the same way as the SUB instruction. This means the value is hardcoded into the instruction itself. The impact on flags follows the same principle as with other subtraction instructions, indicating negative results or borrows.

Examples & Analogies

Think of SUI as if you're directly removing a set amount from your monthly budget. When you plan for expenses that directly reduce what you have, you immediately note the new balance after subtracting this expense. If that subtraction makes your budget negative, you take notice of it—similar to how a borrow flag would alert the CPU here!

Increment and Decrement Operations

Unlock Audio Book

Signup and Enroll to the course for listening the Audio Book

● INR (Increment Register/Memory): Increments the content of a specified register or memory location by 1.

○ INR R: R = R + 1.

■ Example: INR B (If B was 0FH, it becomes 10H).

○ INR M: M = M + 1 (Increments content of memory location pointed by HL).

■ Example: INR M (If HL = 2000H and memory[2000H] = 05H, it becomes 06H).

● DCR (Decrement Register/Memory): Decrements the content of a specified register or memory location by 1.

○ DCR R: R = R - 1.

■ Example: DCR C (If C was 10H, it becomes 0FH).

○ DCR M: M = M - 1 (Decrements content of memory location pointed by HL).

■ Example: DCR M (If HL = 2000H and memory[2000H] = 05H, it becomes 04H).

Detailed Explanation

The INR and DCR instructions are utilized for simple incremental and decremental operations, respectively. They add or subtract 1 from a specific register or a memory location. This is a straightforward operation but has implications for flags, especially if the register reaches zero or its maximum value, indicating overflow or underflow.

Examples & Analogies

Picture an elevator that can only go up one floor at a time (INR) or come down one floor at a time (DCR). Each press of the button moves you one floor up or down. If you reach the top floor (like when the register goes from 0FH to 10H), you keep note, just like how the flags would be updated to show your current floor status in relation to zero.

Definitions & Key Concepts

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

Key Concepts

  • ADD Instruction: Performs addition of register content to the Accumulator, updating flags.

  • ADI Instruction: Adds immediate data to the Accumulator directly.

  • SUB Instruction: Subtracts register content from the Accumulator, affecting status flags.

  • SUI Instruction: Subtracts immediate data from the Accumulator.

  • INR Instruction: Increments a register or memory location by one.

  • DCR Instruction: Decrements a register or memory location by one.

Examples & Real-Life Applications

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

Examples

  • Using the ADD instruction to add the value of Register B to the Accumulator, updating internal flags accordingly.

  • Using the ADI instruction to directly add an immediate value, showing how carry can affect subsequent instructions.

Memory Aids

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

🎵 Rhymes Time

  • ADD, ADI, SUB, oh my! Keeping track of flags makes time fly.

📖 Fascinating Stories

  • Imagine a baker (Accumulator) adding fruits (register content) to a pie. If they add too many (overflow), they need to check the size (Carry flag).

🧠 Other Memory Gems

  • Remember: AAS stands for Add, And Set flags after arithmetic operations.

🎯 Super Acronyms

FACS

  • Flags Affect Carry Status after operations.

Flash Cards

Review key concepts with flashcards.

Glossary of Terms

Review the Definitions for terms.

  • Term: Arithmetic Instructions

    Definition:

    Instructions that perform mathematical operations such as addition, subtraction, increment, and decrement in a microprocessor.

  • Term: Accumulator

    Definition:

    A register in the CPU that temporarily holds data and the results of operations.

  • Term: Carry Flag

    Definition:

    A flag in the status register that indicates whether an arithmetic carry-out has occurred from the most significant bit.

  • Term: Zero Flag

    Definition:

    A flag that indicates whether the result of an operation is zero.

  • Term: Auxiliary Carry Flag

    Definition:

    A flag that indicates whether a carry occurred from bit 3 to bit 4 in BCD operations.

  • Term: Sign Flag

    Definition:

    A flag that indicates the sign of the result, set if the result is negative.

  • Term: Parity Flag

    Definition:

    A flag that indicates whether the number of set bits in the result is even (set) or odd (reset).