Lab 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Lab Sheet for Microprocessor for BEX/BCT/BEL @ IOE, Pulchowk Campus

Lab: 1
Familiarization with data transfer instructions
(Note: Assume the value as hexadecimal if not specified.)
Data Transfer Instructions
Data transfer instructions copy data from the register (or I/O or memory) called the source to another register (or I/O or
memory) called destination. Following different instructions are involved in data transfer. The data transfer instructions
copy data from a source into a destination without modifying the contents of the source. Data transfer instructions do not
affect flags.
a) Immediate Data Transfer
This type of instructions copy the immediate data to the destination register. The mnemonic for the immediate data
transfer are MVI and LXI, which means move immediate data. They are used as follows
MVI R, data (8-bit)
e.g., MVI A, 94 copies immediate data 94H to accumulator register
Load the following program
8000 MVI A, 94 3E
8001 94
8002 RST 5 EF
Run the program in single step mode and examine the content of register A before and after the execution of instruction
MVI A, 94
Output:
Before execution: A= . . . .
After execution: A= . . . .

LXI Rp data (16-bit)


Rp denotes the register pairs BC, DE, HL or SP
e.g. LXI B, 4534 copies immediate data 4534H to register pair BC
Load the following program
8000 LXI B, 2464 01
8001 64
8002 24
8003 RST 5 EF
Run the program in single step mode and examine the content of register pair BC before and after the execution of
instruction LXI B, 2464
Output:
Before execution: B= -------- , C--------
After execution: B= -------- , C--------

Assignment
1. Load 1A, 2B, 3C, 4D, 5E, 6F and 7A to the accumulator, register B, C, D, E, H and L respectively.
Examine the content of each register before and after the execution of each instruction. (Use MVI instruction)
2. Load AABB, CCDD and EEFF into register pair BC, DE and HL respectively. Examine the content of each
register before and after the execution of each instruction. (Use LXI instruction)
b) Transferring data among registers/memory
This type of instructions copy the data from source register/memory to the destination register/memory. The mnemonic
is MOV. It is used as follows
MOV R, R
MOV R, M
MOV M, R
e.g. MOV B, D copies content of register D to register B.
For memory related data transfer the H and L registers are used to hold the memory address.
If register pair HL has 8090H then, MOV B, M copies the content of memory location 8090 to register B.
Load the following program
8000 MVI H, 80 26 80
8002 MVI L, 90 2E 90
8004 MOV B, M 46
8005 MVI L, A0 2E A0

1
8007 MOV M, B 70
8008 RST 5 EF

8090 DATA 33
Run the program in single step mode and examine the contents of register B before and after the execution of MOV
M,B instruction. Also examine the content at memory location 80A0 before and after execution of the program.
Output:
Before execution: B= -------- ,80A0=--------
After execution: B= -------- ,80A0=--------

Assignment
3. Load 4455H and 6677H in register pair BC and DE respectively and exchange their contents. Examine the register
contents before and after execution.
4. Write a program to copy content of memory location at 8080 to 8090.
c) Data transfer from and to memory (load/store)
These types of instructions are used to copy the data from memory to specific registers and from specific registers to
memory.
LHLD, SHLD, LDAX, STAX, LDA, STA are the instructions for this purpose.
LHLD 16-bit (address) copies the contents of the memory location pointed by 16-bit address in register L and
copies the content of next memory location in register H.
SHLD 16-bit (address) copies the contents of register pair HL to the memory location pointed by 16-bit
address.
LDAX B/D copies the content of memory location pointed by register pair BC or DE to accumulator.
STAX B/D copies the content of accumulator to memory location pointed by register pair BC or DE.
LDA 16-bit (address) copies the contents of a memory location specified by 16-bit address to accumulator.
STA 16-bit (address) copies the contents of accumulator to the memory location specified by 16-bit address.
Load the following program
8000 LXI B, 8090 01 90 80
8003 LXI D, 80A0 11 A0 80
8006 LDAX B 0A
8007 STAX D 12
8008 RST 5 EF

8090 DATA AA
Run the program in single step mode and note the contents of accumulator and registers B, C, D and E in each step.
Also note the content of memory address 80A0 before and after execution of STAX D.
Output:
Before execution: 80A0=--------
After execution: 80A0=--------
Reg/Step 1st 2nd 3rd 4th
B
C
D
E

Load the following program


8000 LHLD 8100 2A 00 81
8003 SHLD 8200 22 00 82
8006 RST 5 EF

8100 DATA AA
8101 DATA BB
Run the program in single step mode and note the contents of registers H and L in each step. Also note the content of
memory address 8200 and 8201 before and after execution of SHLD 8200.
Output:
Before execution: 8200=--------,8201=--------------
After execution: 8200=--------,8201=--------------

2
Lab Sheet for Microprocessor for BEX/BCT/BEL @ IOE, Pulchowk Campus

Reg/Step 1st 2nd


H
L

Load the following program


8000 LDA 8050 3A 50 80
8003 STA 8060 32 60 50
8006 RST 5 EF

8050 DATA 99
Run the program in single step mode and note the contents of accumulator in each step. Also note the content of
memory address 8060 before and after execution of STA 8060.
Output:
Before execution: 8060=--------
After execution: 8060=--------
Reg/Step 1st 2nd
A

Assignment
5. Load 11H, 22H, 33H, 44H and 55H into accumulator and registers B, C, D and E respectively, and store these data
in memory location starting at 9000H to 9004H.
6. The data 44H and 66H are stored in memory location 9000H and 9001H respectively. Write a program to transfer
these data to memory location 9050H and 9051H respectively, use LHLD and SHLD instructions.
d) Exchanging the contents of register pair DE and HL
This type of instructions is used to exchange the contents of register pair DE with the contents of register pair HL. The
content of register D is exchanged with the content of register H, and the content of register E is exchanged with the
content of register L. The mnemonic XCHG is used to exchange data between register pairs DE and HL.
Load the following program
8000 LXI D 2233 11 33 22
8003 LXI H 5566 21 66 55
8006 XCHG EB
8007 RST 5 EF
Run the program in single step mode and examine the contents of register pairs DE and HL before and after execution
of XCHG instruction.
Output:
Before execution: DE=------------ HL=---------
After execution: DE=------------ HL=---------

Assignment
7. Write a program to exchange the content of register pair BC and DE with the use of XCHG instruction. Assume
data AABBH and CCDDH are in register pair BC and DE respectively. Examine the register contents before and
after execution.
e) Sending data to output port
This type of instructions used to transfer the data from accumulator to the output port.
OUT 8-Bit port address
e.g. OUT 40 sends the data from accumulator to output port A.
Load the following program
8000 MVI A, 80 3E 80
8002 OUT 43 D3 43
8004 MVI A, 12 3E 12
8006 LXI B, 3456 01 56 34
8009 OUT 40 D3 40
800B MOV A, B 78
800C OUT 41 D3 41
800E MOV A, C 79
800F OUT 42 D3 42
8011 RST 5 EF

3
Run the program in single step mode and examine the contents of accumulator, register B and C, and output ports after
execution of each instructions.

Output:
Reg/Step 1st 2nd 3rd 4th 5th 6th 7th 8th 9th
A
B
C
Port A (40)
Port B (41)
Port C (42)

You might also like