0% found this document useful (0 votes)
58 views5 pages

Micro CH 4 Ex

The document contains exercises related to data transfer, arithmetic, logical, and branch instructions in assembly language. It includes specific instructions and expected outcomes for various operations on registers and memory locations. Additionally, it provides solutions for programming tasks that require efficient use of memory and execution time.
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)
58 views5 pages

Micro CH 4 Ex

The document contains exercises related to data transfer, arithmetic, logical, and branch instructions in assembly language. It includes specific instructions and expected outcomes for various operations on registers and memory locations. Additionally, it provides solutions for programming tasks that require efficient use of memory and execution time.
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/ 5

Exercises on Chapter 4

1- Data Transfer Instructions:


1. What are the contents of registers A, B and C after the execution of the following
instructions?

MVI..........B, 0FH ; (B) = 0FH


MVI..........C, FFH ; (C) = FFH
MVI..........A, 00H ; (A) = 00H
STA.......0.2400H ; (2500H) = 00H
LXI..........H, 2402 H ; (H) = 24H, (L) = 02H or (H)(L) = 2402H
MOV........M, C ; (2402H) = FFH
MOV........A, B ; (A) = 0FH
LDA.........2402 H ; (A) = FFH

2. The contents of memory locations 2400H, 2401H, 2402H and 2403H are 00, FFH, 0FH
and 1AH respectively. What will be the memory contents after the following instructions
are executed?

LHLD..........2402H ; (L) = 0FH, (H) = 1AH


LDA............2400H ; (A) = 00H
MOV............B, L ; (B) = 0FH
MOV............C, H ; (C) = 1AH
MVI.............D, 03 ; (D) = 03H
MOV............E, A ; (E) = 00H
SHLD..........2400H ; (2400H) = 0FH, (2401H) = 1AH
STA.............2402H ; (2402H) = 00H
(2403H) = 1AH, has no change.

3. A value 05H is to be stored at memory locations 2000H, 2001H and 2002H. Write the
different programs to perform this. Select the program that will take the least amount of
memory and time to execute. Use only the instructions covered so far.

Solution:
MVI A, 05H
STA 2000H
STA 2001H

1
STA 2002H

Or:

MVI H, 05H
MVI L, 05H
SHLD 2000H
SHLD 2001H

Or:

LXI H, 2000H
MVI M, 05H
LXI H, 2001H
MVI M, 05H
LXI H, 2002H
MVI M, 05H

2- Arithmetic Instructions:
1. Five memory locations 2401H, 2402H, 2403H, 2404H, and 2405H have some data items
called X1, X2, X3, X4, and X5 respectively. Write a program to calculate and store in
different memory locations as in the following:

(2401H) = X1 + X5
(2402H) = X5 – X2
(2403H) = X4 + X1 + X3
(2404H) = X4 – X1 – X2
(2405H) = X1 + X2 + X3 + X4
Solution:
LXI H, 2401H
MOV B, M ; (B) = X1
LDA 2405H
ADD B
STA 2401H (or MOV M, A) → 1
INX H

2
MOV C, M ; (C) = X2
LDA 2405H
SUB C
MOV M, A → 2
INX H
MOV D, M ; (D) = X3
LDA 2404H
ADD B
ADD D
MOV M, A → 3
INX H
LDA 2404H (or MOV A, M)
SUB B
SUB C
MOV M, A → 4
INX H
LDA 2404H
ADD B
ADD C
ADD D
MOV M, A → 5

3- Logical Instructions:
1. Three numbers X1, X2 and X3 are stored at 2000H, 2001H and 2002H respectively.
Write programs to calculate Z1, Z2 and Z3 as per the following and store the result at
2100H, 2101H and 2102H respectively.

Z1 = (X1 OR X2) AND X3

3
Z2 = (X1 + X3) XOR X2
Z3 = (X3 – X1) AND X2
Solution:
1) LDA 2000H
LHLD 2001H ; (L) = X2, (H) = X3
ORA L
ANA H
STA 2100H
2) LDA 2000H
LHLD 2001H ; (L) = X2, (H) = X3
ADD H
XRA L
STA 2101H
3) LDA 2002H
LHLD 2000H ; (L) = X1, (H) = X2
SUB L
ANA H
STA 2102H

3. What will be the values in registers A, H, L and locations 2400H, 2401H, 2500H and
2501H after the execution of the following instructions?

LXI.............. .H, 2400 ; (H)(L) = 2400H


MVI...............A, 08H ; (A) = 08H
MOV..............M, A ; (2400H) = 08H
INX................H ; (H)(L) = 2401H
SUI................02 H ; (A) = (A) – 02H = 06 H
MOV..............M, A ; (2401H) = 06H
LHLD............2400H ; (L) = 08H, (H) = 06H
SHLD............2500H ; (2500H) = 08H, (2501H) = 06H
LDA..............2501H ; (A) = 06H

4
RLC ; (A) = 0CH
RLC ; (A) = 18H
RLC ; (A) = 30H
ANI. ..............98H ; (A) = 10H

4- Branch Instructions

5. Two numbers X and Y are stored in memory. Calculate the value of the expression (X +
Y – 100). If the value is negative, calculate the value of Z1 and store; otherwise, calculate
the value of Z2 and store in memory. The equations pertaining to Z1 and Z2 are as
follows:

Z 1 =X AND Y
Z 2 = X OR Y
Solution:
LDA 2000H ; (A) = X
LXI H, 2001H
MOV B, M ; (B) = Y
ADD B ; (A) = X+Y
SUI 64H (or CPI 64H)
J M Z1 ( or J C Z1)
LDA 2000H
ORA B
JMP END
Z1: LDA 2000H
ANA B
END: STA 2100H

You might also like