Lab 2 PDF
Lab 2 PDF
Instructions:
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 D,16bit
LXI H,16bit
LXI SP,16bit
LXI H,2050H
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.
It copies the data byte from the memory location into the accumulator
It copies the data byte from the memory location specified by 16 bit address in the second and third
byte.
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
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
It treats the contents of two registers as one 16 bit number and increases the contents by 1.
INX D
INX H
INX SP
DCX B
DCX D
DCX H
DCX SP
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.
NEXT:MOV A,M
STAX D
HLT
ADD M/SUB M: Add/subtract the contents of a memory location to/from the contents of the
accumulator.
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.
This is a 1-byte instruction. It subtracts memory from Accumulator and stores the result in A.
3. INR M
It is a 1- byte instruction. It increments the contents of memory location by 1, not the memory address.
4. DCR M
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