microprocessor LAB
microprocessor LAB
The following instructions are used in the program for data transfer operations:
HLT (Halt)
Syntax: HLT
Explanation: This instruction halts the execution of the program. It signals the
microprocessor to stop executing further instructions.
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.
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.
5. Program Flow
HLT Instruction: The program ends after execution of the HLT instruction,
which stops the processor.
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
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:
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
Explanation:
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
Explanation:
assembly
8085 Program for Data Transfer from Register to Register and
Register to Memory
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:
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).
To perform the addition operations, we will use the following 8085 instructions:
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.
Syntax: DCR R
Explanation: The DCR instruction decrements the contents of a register by 1.
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.
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.
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.
For example, adding two decimal numbers, 25 and 37 (which are 25H and 37H in
hexadecimal), would proceed as follows:
1.
Load Numbers:
2.
3.
4.
5.
6.
o If the sum exceeds 9, use DCR to check and adjust with ADI 06H for BCD
correction.
7.
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.
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
CORRECT:
ADI 06H ; Add 06H for BCD correction
HLT ; Halt the program
Explanation:
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
Explanation:
1.
2.
3.
ADD: This instruction adds the contents of a register to the accumulator.
4.
5.
6.
7.
JC (Jump if Carry): This instruction causes a jump if the carry flag is set
(after addition, if a correction is needed).
8.
9.
10.
1. ADI 06H: Adds 06H for BCD correction in case of decimal addition.
11.
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).