CS II-Program 7
CS II-Program 7
CS II-Program 7
Aim: Write a program to find how many times ADH appears in memory block starting from
2030H and length of block is at 202f H store the count in 3000H.
Algorithm:
1. Initialize C register with zero and A register with ADH.
2. Compare data in memory location is equal to ADH. If yes increment counter by
one if no increment memory location.
3. Repeat the comparison unless ptr is equal to zero.
4. Store the result at memory location 3000H.
5. Stop program execution.
Flowchart
PROGRAM
Mnemonics
Address Label Opcode Operand Hexacode Comment
2000 START MVI C, 00 0E Move 00 to C register
2001 00 _
2002 MVI A, ADH 3E Move AD data to A register
2003 ADH _
2004 LXI H, 202FH 21 Initialize HL with 202fH
2005 2F Lower address byte
2006 20 Upper address byte
2007 MOV B, M 46 Move memory data to B register
2008 INX H 23 Increament HL by 1
OUTPUT
Before execution After Execution
Memory
location Memory
Data loaction Data
202F 04 202F 04
2030 12 2030 12
2031 AD 2031 AD
2032 34 2032 34
2033 AD 2033 AD
3000 02