0% found this document useful (0 votes)
112 views7 pages

Lab 2 PDF

The document provides instructions on using the 8085 microprocessor, including loading 16-bit data into register pairs, transferring data between memory and registers, arithmetic operations on memory contents, and using the stack and subroutines. It describes instructions to load, increment, decrement, add, and subtract 16-bit register pairs and 8-bit memory values. Examples show how to transfer blocks of data between memory locations using pointers, counters, and looping.

Uploaded by

Smarajit Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views7 pages

Lab 2 PDF

The document provides instructions on using the 8085 microprocessor, including loading 16-bit data into register pairs, transferring data between memory and registers, arithmetic operations on memory contents, and using the stack and subroutines. It describes instructions to load, increment, decrement, add, and subtract 16-bit register pairs and 8-bit memory values. Examples show how to transfer blocks of data between memory locations using pointers, counters, and looping.

Uploaded by

Smarajit Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Lab-2

Instructions:

1. 16- bit data transfer to register pairs (LXI)

LXI instruction load 16- bit data in register pairs and stack pointer register. LXI is a 3-byte instruction. It
requires 3-bytes of memory and 10 clock periods(T-states). These instructions do not affect the flags.

LXI Rp,16 bit

LXI B,16 bit

LXI D,16bit

LXI H,16bit

LXI SP,16bit

Program 1: Load 16 -bit number 2050H in register pair HL

LXI H,2050H

Load HL registers; 50H in L registers and 20H in H registers.

2. Data Transfer from Memory to Microprocessor

The 8085-instruction set includes three types of memory transfer instructions: two use the indirect
addressing mode and one-use direct addressing mode. These instructions do not affect the flags.
1. MOV R, M: Move (from Memory to Register)
This is a 1-byte instruction.
It copies the data byte from the memory location into a register.
R represent register-A,B,C,D,E,H,L
The memory location is specified by the contents of HL register.
It is indirect addressing mode.

2. LDAX B/D: Load Accumulator Indirect

This is a 1-byte instruction.

It copies the data byte from the memory location into the accumulator

The memory location is specified by the contents of the register BC/DE.

The addressing mode is indirect.

3. LDA 16-bit: Load Accumulator Direct


This is a 3 byte instruction.

It copies the data byte from the memory location specified by 16 bit address in the second and third
byte.

Addressing mode is direct.

Prog2: The memory location 2050H holds data byte F7H. Write instructions to transfer the data byte
to the accumulator.

LXI H,2050H

MOV A, M

Or

LXI B,2050H

LDAX B

Or

LDA 2050H

4. Data Transfer from microprocessor to memory or directly into memory


1. MOV M, R: Move from Register to Memory
This is a 1-byte instruction that copies data from a register R, into a memory location specified by the
contents of HL registers.

2. STAX B/D: Store Accumulator Indirect

This is a 1-byte instruction that copies data from the accumulator into the memory location specified by
the contents of either BC or DE registers.

STAX B

STAX D
3. STA 16bit: Store Accumulator Direct

This is a 3-byte instruction that copies data from the accumulator into the memory location specified by
the 16-bit operand.

4. MVI M,8-bit:
Load 8-bit data in memory.
This is a two-byte instruction the second byte specifies 8-bit data.
The memory location is specified by the contents of the HL register.

Program 5. Register B contains 32H. Copy contents of register B into the memory location
8000H.

LXI H,8000H
MOV M,B

Or
LXI D,8000H
MOV A,B
STAX D

Program 6. The accumulator contains F2H. Copy content of Accumulator into memory location
8000H using direct addressing.

STA 8000H

Program 7.: Load F2H directly in memory location 8000H using indirect addressing.
LXI H,8000H
MVI M, F2H

Arithmetic Operations related to 16 bits or register pairs


The instruction related to incrementing/decrementing 16-bit contents in a register pair are given
below:
1. INX Rp: Increment Register Pair

This is a 1- byte instruction.

It treats the contents of two registers as one 16 bit number and increases the contents by 1.

The instruction set includes four instructions.


INX B

INX D

INX H

INX SP

2. DCX Rp: Decrement Register Pair

DCX B

DCX D

DCX H

DCX SP

This is a 1-byte instruction.

It decreases the 16 bit contents of a register pair by 1

It includes four instructions.

Program: Load the number 2050H in the register pair BC. Increment the number using the instruction
INX B .

LXI B,2050H

INX B

Note: Indirect addressing using HL as a memory pointer. The HL registers can be used to copy between
any one of the registers and memory. Any instruction with the operand M automatically assumes the HL
is the memory pointer.

Indirect addressing using BC and DE as memory pointer. The instructions LDAX and STAX use BC and DE
as memory pointers. This is restricted to copying from and into the accumulator and cannot be used for
other registers.

Direct addressing using LDA and STA instructions. These instructions include memory address as the
operand. This method is also restricted to copying from and into the accumulator.

Program: Sixteen bytes of data are stored in memory locations at XX50H to XX5FH. Transfer the entire
block of data to new memory locations starting at XX70H.

LXI H,XX50H // pointer for source memory


LXI D,XX70H // pointer for destination memory

MVI B,10H // set up counter

NEXT:MOV A,M

STAX D

INX H // increment source memory

INX D // increment destination memory

DCR B // decrement counter

JNZ NEXT // if counter B is not zero jump to Next

HLT

Arithmetic Operations Related to memory

ADD M/SUB M: Add/subtract the contents of a memory location to/from the contents of the
accumulator.

INR M/DCR M: Increment/Decrement the contents of a memory location.

1. ADD M Add Memory

This is a 1-byte instruction. It adds Memory to accumulator and store the result in A. The memory
location is specified by the contents of HL register.

2. SUB M Subtract Memory

This is a 1-byte instruction. It subtracts memory from Accumulator and stores the result in A.

The memory location is specified by HL.

3. INR M

It is a 1- byte instruction. It increments the contents of memory location by 1, not the memory address.

The memory location is specified by HL

All flags except the carry flag are affected.

4. DCR M

This is a 1-byte instruction.

It decrements M by 1
The memory location is specified by HL

Program: Add the contents of the memory location 2040H to accumulator and subtract the contents
of the memory location 2041H from the first sum. Assume accumulator has 30H, the memory location
2040H has 68H and the location 2041H has 7FH.

MVI A,68H

STA 2040H

MVI A,7FH

STA 2041H

MOV A,30H

LXI H,2040H

ADD M

INX H

SUB M

Program: Load 59H in memory location 2040H and increment the content of the memory
location. Also, load 90H in memory location 2041h and decrement the contents of the
memory location.

MVI A, 59H
STA 2040H
LXI H,2040H
INR M
MVI A,90H
STA 2041H
LXI H,2041H
DCR M

OR

LXI H,2040H
MVI M,59H
INR M
INX H
MVI M,90H
DCR M
Stack and Subroutines
LXI SP,16-bit Load stack pointer with a 16-bit address.
PUSH Rp Store Register Pair on stack. This is a 1-byte instruction. It copies the
contents of the specified register pair on the stack.
PUSH B
PUSH D
PUSH H
PUSH PSW

Assignment

1. Find the 1’s and 2’s complement of an 8-bit number stored in Memory.
a. 8-bit number
b. 16-bit number
2. Addition of two 8-bit number stored in Memory:
a. Result in 8-bit,
b. Result in 16-bit
3. Subtraction of two 8-bit number stored in Memory
a. Using SUB instruction
b. Without using SUB instruction
4. Move a Block of data from one memory locations to another memory locations

You might also like