CS2 Solutions
CS2 Solutions
Algorithm
1 Start
6. Store the accumulator data into the memory location pointed by DE register pair.
10 Stop
COO9H 12 STAX D
COOAH 2B DCXH
COOBH 13 INX D
COOCH OD DCR C
COODH C2 JNZ Back
COOEH 08
COOFH CO
CO1OH CF RST1
Memory Table
Input
Output
Register value
Flag Register
Algorithm
1 Start
11.Increment DE pair by 1.
Q.Write a program that subtracts the number stored in C031H
from the number stored in C030H. Store the absolute difference
in memory location C090H as result.
Algorithm:
1 Start:
3 Copy the contents from the memory location pointed by HL pair into accumulator.
4 Increase HL pair by 1.
5.Subtract the data of memory location pointed by HL pair from the contents of
Accumulator.
10 Stop.
Q.A block of data is stored in memory location from C030H to
C039H. Write a program to find the number of odd as well as
even number in the given block. Store the results immediately
after the end of block.
Algorithm
1.Start
9.Increase register B by 1.
11.Increase register D by 1.
12 Increase HL pair by 1.
13.Decrease register C by 1.
15.copy the data from register C into the memory location pointed by HL pair.
16.Increase HL pair by 1
17.copy the data from register C into the memory location pointed by HL pair.
18.stop
Hex Table
Q.Write a program that multiplies two 1 byte hex numbers
stored in consecutive memory locations starting from C030H.
Store the two byte result in consecutive memory location
starting from C090H beginning with lower order byte.
Algorithm:-
1.Start.
4.Increment HL pair by 1.
accumulator..
11.Decrement register C by 1.
15 Increment HL pair by 1.
17 Stop.
1.Start
5 Increment HL pair by 1.
9 If CY # 0 then go to step 13
17Increment HL pair by 1.
18 Decrement register c by 1.
21 Increment HL pais by 1.
23 Stop
Memory Label Hex mnemonics comments.
Location code
to register B .
CO12H IC
CO13H CO
contents of register D.
COI6H 1C
COI7H CO
COI9H 1C
COIAH CO
to register D .
CO2OH 00
CO3OH 05 05
COBIH 02 02
CO32H oa 09
CO33H 06 06
CO34H 03 03
CO35H 01 01
CO36H 01 01
CO37A 08 08
CO38H 04 04
CO39H OA OA
Output
COBAH - 01
CO3BH - OA
Register value
A OA H CO
B 01 L 3B
C 00 SPH 84
D OA SPL 21
E 9A PCH CO
F 40 PCL 25
Flag Register
S Z X AC X P X CY
0 1 - 0 - 0 - 0
Conclusion:
Thus we have executed the program to find out the smallest as well as largest
number out of the block.
Q.A block of data is stored in memory location C030H. The length of
the block is10 bytes. Write a program that sorts the given data in
ascending order.
HEx Table
Q.Write a program to convert a 2-digit BCD number stores at memory
location C030H in to its binary equivalent and store the binary value in
memory location C090H.