Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

microprocessor LAB

The document outlines two experiments using the 8085 Microprocessor: data transfer operations between registers and memory, and decimal/hexadecimal addition of two numbers. It details the architecture, key registers, instructions, and program flow necessary for these operations. The examples provided illustrate the use of specific instructions like MVI, MOV, STA, ADD, and their roles in executing the respective tasks.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

microprocessor LAB

The document outlines two experiments using the 8085 Microprocessor: data transfer operations between registers and memory, and decimal/hexadecimal addition of two numbers. It details the architecture, key registers, instructions, and program flow necessary for these operations. The examples provided illustrate the use of specific instructions like MVI, MOV, STA, ADD, and their roles in executing the respective tasks.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

EXPERIMENT 1

Write a program using 8085 Microprocessor for data transfer from


register to register and register to memory.

the prerequisites used in the 8085 Microprocessor program


for data transfer, specifically focusing on the instructions,
concepts, and registers involved in transferring data
between registers and memory. Here is a detailed
breakdown of the key components:
1. 8085 Microprocessor Architecture Overview

The Intel 8085 microprocessor is an 8-bit processor, meaning it processes


8 bits of data at a time. It has several internal registers, a set of
instructions, and memory addressing capabilities.

Key Registers in 8085:

 Accumulator (A): This is an 8-bit register used for arithmetic and


logical operations.
 General Purpose Registers (B, C, D, E, H, L): These are used to
store intermediate data. Each of these registers is 8 bits wide.
 Memory Address Registers: The HL pair is often used for
addressing memory locations.
 Program Counter (PC): This is a 16-bit register that holds the
address of the next instruction to be executed.
 Stack Pointer (SP): It points to the top of the stack in memory.
 Status Flags: These are used to store the result of operations, such
as zero, sign, carry, parity, and auxiliary carry.

2. 8085 Instructions Used in the Program

The following instructions are used in the program for data transfer operations:

MVI (Move Immediate)

 Syntax: MVI R, data


 Explanation: This instruction is used to load an immediate 8-bit value (data)
into a register R.
 In the program, MVI A, 55H loads the value 55H into the accumulator (A
register). Similarly, MVI A, 30H loads 30H into the accumulator.
MOV (Move Data)

 Syntax: MOV R1, R2


 Explanation: This instruction copies the contents of register R2 to register
R1. It is a register-to-register transfer.
 In the program, MOV B, A copies the contents of register A (which holds
data 55H from the previous MVI instruction) to register B.

STA (Store Accumulator to Memory)

 Syntax: STA addr


 Explanation: This instruction stores the contents of the accumulator (A
register) into a specified memory address.
 In the program, STA 2000H stores the contents of the accumulator (which
holds 30H) into memory location 2000H.

HLT (Halt)

 Syntax: HLT
 Explanation: This instruction halts the execution of the program. It signals the
microprocessor to stop executing further instructions.

3. Memory and Addressing in 8085

Memory: The 8085 microprocessor can address a memory space from 0000H
to FFFFH (64KB total). It uses a 16-bit address bus to access 16-bit memory
locations.


STA Instruction and Memory Address:

o In the program, STA 2000H refers to storing data into a specific memory
address (2000H). This instruction will write the value of the accumulator
into memory location 2000H.
o The memory is organized in 8-bit chunks, so each memory address can
hold 1 byte of data.

4. Data Transfer Operation Breakdown

Register to Register (MOV instruction):


o In this program, the data in the accumulator (A register) is moved to


register B using the MOV B, A instruction.
o MOV is a simple instruction used for copying data between registers.
This does not modify the original register.

Register to Memory (STA instruction):

o In the second part of the program, the contents of the accumulator (A


register) are stored in memory location 2000H using the STA
instruction.
o The STA instruction writes the value in the accumulator into a
memory address, which is specified as a 16-bit value.

5. Program Flow

Program Counter (PC): The PC keeps track of the next instruction to be


executed. After each instruction, the PC is incremented to point to the address
of the next instruction in memory.


HLT Instruction: The program ends after execution of the HLT instruction,
which stops the processor.

6. Instruction Cycle and Timing

Each instruction executed by the 8085 microprocessor goes through several machine
cycles:

 Opcode Fetch Cycle: The microprocessor fetches the opcode (the operation
part of the instruction).
 Memory Read/Write Cycle: When accessing memory, the microprocessor
either reads data from or writes data to the memory.
 The execution of the MVI, MOV, and STA instructions would involve opcode
fetches, along with the appropriate read or write cycles depending on
whether data is being moved between registers or stored in memory.
Example Program Breakdown:

assembly
Copy code
; 8085 Program for Data Transfer from Register to Register and
Register to Memory

; Step 1: Register to Register Transfer (A to B)


MVI A, 55H ; Load immediate data 55H into register A
MOV B, A ; Move the contents of A to B

; Step 2: Register to Memory Transfer (A to memory location


2000H)
MVI A, 30H ; Load immediate data 30H into register A
STA 2000H ; Store the contents of A into memory location
2000H

HLT ; Halt the program

Explanation of Prerequisites Used in the Program:

 Registers: The program uses the A, B registers, and memory locations.


Registers are used for holding temporary data.
 Instruction Set: The program uses MVI for loading immediate data, MOV for
moving data between registers, STA for storing data in memory, and HLT for
halting the program.
 Memory Addressing: We access memory using the STA instruction, which
specifies the target memory address for storing data.
 Program Flow: Instructions are executed sequentially, and the program stops
at the HLT instruction.

Conclusion

This program demonstrates basic data transfer operations using the 8085
microprocessor. It transfers data from one register to another using MOV and from a
register to memory using STA. The key prerequisites involve understanding the 8085
registers, instructions, memory addressing, and the flow of program execution in a
microprocessor system.
Write a program using 8085 Microprocessor for data transfer
from register to register and register to memory

To write a program for data transfer using the 8085 microprocessor, let's break it
down into two parts:

1. Register to Register Data Transfer


2. Register to Memory Data Transfer

1. Register to Register Data Transfer

For this operation, we will move data from one register to another using the MOV
instruction in 8085. Here's an example of transferring data from register A to register
B.

Program Explanation:

 We will assume that register A holds some data, and we want to move it to register B.

assembly

; Register to Register Data Transfer Example

MVI A, 55H ; Load immediate data 55H into register A


MOV B, A ; Move the contents of A to B

HLT ; Halt the program

Explanation:

 MVI A, 55H loads the value 55H into register A.


 MOV B, A moves the data from register A to register B.
 HLT halts the program.

2. Register to Memory Data Transfer

Now, let's transfer the contents of a register (e.g., register A) to a memory location.

Program Explanation:

 We will assume the data in register A is transferred to a specific memory location (e.g.,
2000H).

assembly
; Register to Memory Data Transfer Example
MVI A, 30H ; Load immediate data 30H into register A
STA 2000H ; Store the contents of A into memory location
2000H

HLT ; Halt the program

Explanation:

 MVI A, 30H loads the value 30H into register A.


 STA 2000H stores the contents of register A into memory location 2000H.
 HLT halts the program.

Full Example Code for Both Operations

assembly
8085 Program for Data Transfer from Register to Register and
Register to Memory

; Step 1: Register to Register Transfer (A to B)


MVI A, 55H ; Load immediate data 55H into register A
MOV B, A ; Move the contents of A to B

; Step 2: Register to Memory Transfer (A to memory location


2000H)
MVI A, 30H ; Load immediate data 30H into register A
STA 2000H ; Store the contents of A into memory location
2000H

HLT ; Halt the program

Explanation of Instructions Used:


 MVI: Load immediate data into a register (8-bit value).
 MOV: Transfer data from one register to another.
 STA: Store the contents of a register into a memory location.
 HLT: Halt the program execution.

This code demonstrates both types of data transfer in the 8085 microprocessor:
Register to Register and Register to Memory.
EXPERIMENT 2
Write a program using 8085 Microprocessor for Decimal,
Hexadecimal addition of two Numbers.
the prerequisites required for the 8085 Microprocessor program for Decimal and
Hexadecimal addition of two numbers, we need to look at the 8085
microprocessor's architecture, its instructions, and how decimal and hexadecimal
arithmetic is handled within the context of the 8085 microprocessor. Below is a
detailed explanation of all the prerequisites:

1. 8085 Microprocessor Overview

The Intel 8085 is an 8-bit microprocessor, which means that it processes data in 8-bit
chunks. It has a 16-bit address bus and a 16-bit program counter, which allows it to
address up to 64KB of memory. The 8085 has a set of general-purpose registers (A,
B, C, D, E, H, L) and a set of special-purpose registers (Program Counter, Stack
Pointer).

Key components for this program:

 Accumulator (A): An 8-bit register used for arithmetic operations.


 General-purpose registers (B, C, D, E, H, L): These can be used for storing intermediate
results or data.
 Flags: The 8085 microprocessor has five flags—sign, zero, auxiliary carry, parity, and carry.
The carry flag will be particularly important in addition.

2. Hexadecimal and Decimal Representation


Decimal (BCD): The Binary-Coded Decimal (BCD) format is used to


represent decimal digits in binary form. Each 8-bit byte holds two decimal
digits (4 bits per digit), which range from 0 to 9. For example, 25 in decimal is
represented as 00100101 in binary.


Hexadecimal: In hexadecimal, each digit is represented by 4 bits.


Hexadecimal values range from 0 to F, where F represents 15 in decimal. For
example, 3A in hexadecimal is 00111010 in binary, which is equal to 58 in
decimal.

3. Important 8085 Instructions Used

To perform the addition operations, we will use the following 8085 instructions:

1. MVI (Move Immediate)

 Syntax: MVI R, data


 Explanation: The MVI instruction is used to load an immediate value into a register.

o Example: MVI A, 25H loads the hexadecimal value 25H into the accumulator (A
register).

2. ADD (Add)

 Syntax: ADD R
 Explanation: The ADD instruction adds the contents of a register to the accumulator.

o Example: ADD B adds the contents of register B to the accumulator.

3. DCR (Decrement Register)

 Syntax: DCR R
 Explanation: The DCR instruction decrements the contents of a register by 1.

o Example: DCR A decrements register A by 1. This is used in BCD correction to adjust


the result if the sum exceeds the decimal value of 9.

4. JC (Jump if Carry)

 Syntax: JC label
 Explanation: The JC instruction checks the carry flag. If the carry flag is set (i.e., the addition
resulted in a carry), it will jump to the specified label.

o Example: JC CORRECT jumps to the label CORRECT if there is a carry after the
addition.

5. ADI (Add Immediate)

 Syntax: ADI data


 Explanation: The ADI instruction adds an immediate value to the accumulator.

o Example: ADI 06H adds 06H (BCD correction value) to the accumulator.

6. HLT (Halt)

 Syntax: HLT
 Explanation: The HLT instruction stops the execution of the program. It's used to halt the
program after the addition is complete.
4. Arithmetic Operation on the 8085
 Addition of Two Numbers:

o In both decimal and hexadecimal addition, the 8085 microprocessor uses its
accumulator (A register) to hold the result of the addition.
o The carry flag plays an important role in handling overflow situations. If the sum of
two numbers exceeds the capacity of an 8-bit register (255 in decimal or FF in
hexadecimal), the carry flag is set to 1.
o Carry in Decimal Addition (BCD): For Decimal addition, the 8085 uses BCD (Binary-
Coded Decimal) correction if the result exceeds 9. This correction involves checking
if the sum is greater than 9 and then adding 06H (which is 6 in decimal) to the
result to adjust it back into the valid BCD range.

5. Decimal (BCD) Addition

In decimal addition, we must ensure that the sum of the two decimal numbers is
within the range 00 to 99 in BCD format. Here's how this works:

If the sum of the two numbers is greater than 9, a carry is generated, and we
need to add a correction value (06H in hexadecimal) to ensure the result is still
a valid BCD number.


For example:

o When adding 7 + 8, the sum is 15, which is beyond the BCD range. To correct this,
we would add 6 (which is 06H in hexadecimal) to the result to keep the value valid.

6. Program Flow and Error Handling


 The carry flag is crucial in addition to detect whether a carry occurred (if the sum exceeds
the maximum value for 8-bit numbers).
 The program should check for overflow conditions in decimal (i.e., when the result exceeds 9
in BCD) and adjust accordingly.
 The JC (Jump if Carry) instruction is used to correct the result in BCD mode when the sum
exceeds 9.

Example Breakdown of Decimal Addition:

For example, adding two decimal numbers, 25 and 37 (which are 25H and 37H in
hexadecimal), would proceed as follows:

1.
Load Numbers:

2.

o Load 25H into the accumulator (MVI A, 25H).


o Load 37H into register B (MVI B, 37H).

3.

Add the Numbers:

4.

o Add the contents of register B to the accumulator (ADD B).

5.

Check for Carry:

6.

o If the sum exceeds 9, use DCR to check and adjust with ADI 06H for BCD
correction.

7.

Output the Result:

8.

o The result is stored in the accumulator and can be used further, or the program can
stop with the HLT instruction.

Conclusion

The prerequisites for the 8085 Microprocessor program for Decimal and
Hexadecimal addition of two numbers include:

 Registers: The accumulator (A) and general-purpose registers (B, etc.) are used to store
intermediate and final results.
 Instructions: MVI, ADD, DCR, JC, ADI, and HLT are the key instructions used to perform the
addition and handle corrections for decimal addition.
 Carry Flag: This flag is crucial to detect overflows and ensure correct handling of the sum
when it exceeds the range of the register (in both decimal and hexadecimal cases).
 Program Flow: Proper handling of the program's flow using jump instructions (JC) to
manage cases where corrections are needed in decimal addition.

This knowledge ensures that the 8085 microprocessor can perform both decimal and
hexadecimal addition correctly, accounting for overflows and necessary corrections
in the case of decimal numbers.
Write a program using 8085 Microprocessor for Decimal,
Hexadecimal addition of two Numbers

1. Decimal Addition:

In the 8085 microprocessor, you can add two decimal numbers directly using the ADD
instruction. However, you need to keep in mind that if the result exceeds 9, you need
to perform a BCD (Binary-Coded Decimal) correction. This correction is done by
checking the carry and adding 6 (which is 06H in hexadecimal) to the result.

2. Hexadecimal Addition:

For hexadecimal addition, the addition can be done directly using the ADD instruction
without needing any special corrections, as hexadecimal numbers fit within the 8-bit
register capacity.

Program for Decimal Addition:

This program will perform decimal addition (BCD mode) of two numbers. For
simplicity, let's assume the numbers to be added are 25 and 37 (in decimal).

Program:

assembly
Copy code
; Decimal Addition (BCD)
MVI A, 25H ; Load the first number (25 in decimal) into
register A
MVI B, 37H ; Load the second number (37 in decimal) into
register B

ADD B ; Add the contents of B to A (A = A + B)

DCR A ; Decrement A by 1 (correction step)


JC CORRECT ; Jump if carry (correction needed)

HLT ; Halt the program if no correction is needed

CORRECT:
ADI 06H ; Add 06H for BCD correction
HLT ; Halt the program
Explanation:

1. MVI A, 25H loads 25 (in decimal) into the accumulator (A register).


2. MVI B, 37H loads 37 (in decimal) into register B.
3. ADD B adds the value in register B to the accumulator (A).
4. The DCR A instruction decrements the accumulator by 1 and the JC CORRECT instruction
checks if a correction is needed (if the carry flag is set).
5. If a correction is needed (i.e., if the sum exceeds 9), we add 06H (BCD correction).
6. The program halts after the addition.

Program for Hexadecimal Addition:

This program will perform Hexadecimal addition of two numbers. Let's assume we
are adding 0x3A and 0x17 (i.e., 58 and 23 in decimal).

Program:

assembly
Copy code
; Hexadecimal Addition
MVI A, 3AH ; Load the first number (0x3A) into register A
MVI B, 17H ; Load the second number (0x17) into register B

ADD B ; Add the contents of B to A (A = A + B)

HLT ; Halt the program

Explanation:

1. MVI A, 3AH loads 0x3A (58 in decimal) into register A.


2. MVI B, 17H loads 0x17 (23 in decimal) into register B.
3. ADD B adds the value of register B to the accumulator (A).
4. The program halts after the addition.

Summary of Key Instructions Used:

1.

MVI (Move Immediate): This instruction is used to load an immediate 8-bit


value into a register.

2.

1. MVI A, 25H: Loads 25 into the accumulator.


2. MVI B, 37H: Loads 37 into register B.

3.
ADD: This instruction adds the contents of a register to the accumulator.

4.

1. ADD B: Adds the contents of register B to register A.

5.

DCR (Decrement Register): This instruction decrements the value of a


register by 1.

6.

1. DCR A: Decrements register A by 1, used for BCD correction.

7.

JC (Jump if Carry): This instruction causes a jump if the carry flag is set
(after addition, if a correction is needed).

8.

1. JC CORRECT: Jumps to the correction part if there is a carry.

9.

ADI (Add Immediate): This instruction adds an immediate value to the


accumulator.

10.

1. ADI 06H: Adds 06H for BCD correction in case of decimal addition.

11.

HLT (Halt): Stops the execution of the program.

12.

Conclusion:
 The Decimal Addition program accounts for BCD corrections if the sum exceeds 9.
 The Hexadecimal Addition program directly adds the numbers without any need for special
correction as hexadecimal addition fits within 8 bits.
Both programs perform simple addition of two numbers but differ based on the type
of number system used (BCD for decimal and standard 8-bit arithmetic for
hexadecimal).

You might also like