0% found this document useful (0 votes)
9 views2 pages

CS II-Program 9

Uploaded by

spamacc938
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)
9 views2 pages

CS II-Program 9

Uploaded by

spamacc938
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/ 2

Program 9

Aim: Write a program to find first occurrence of ABH data. The length of block is stored at
307F H. The data stored from memory location 3080. Store the address of the occurrence in HL
pair. If data is not found store FFFFH in HL pair.

Algorithm:
1. Initialize count with the length of block.
2. Continue loop till count is not equal to zero.
3. If accumulator data and memory data is same store the memory location in HL pair else
continue the loop.
4. If data is not found store FFFFH in HL pair.
5. Stop program execution.

Flowchart:
PROGRAM 11
Mnemonics
Address Label Opcode Operand Hexacode Comment
2000 START LXI H, 307F H 21 HL pointer points to 307f
2001 7F Lower address byte
2002 30 upper address byte

2003 MOV C, M 4E Move memory datat to C register

2004 MVI A, AB H 3E Move serch data AB h to A register


2005 AB _
2006 S1 INX H 23 Increament HL by 1
Compare accumulater data with
2007 CMP M BE memory data

2008 JZ 2012 H CA If zero flag is set jump to label Stop


2009 12 Lower address byte
200A 20 upper address byte
200B DCR C 0D Decreament counter by 1
If C register not zero then go to label
200C JNZ 2006 C2 S1
200D 06 Lower address byte
200E 20 upper address byte
HL pair content ffff as data not
200F LXI H, FFFF H 21 available
2010 FF Lower address byte
2011 FF upper address byte
2012 STOP RST 1 CF Stop program execution

OUTPUT
Before execution After Execution
Memory Memory
loaction Data loaction Data
307f 05 307f 05
3080 21 3080 21
3081 AB 3081 AB
3082 33 3082 33
3083 AB 3083 AB
3084 BC 3084 BC

General Register
A AB
B 01
C 04
D 00
E 00.
F 54
H 30
L 81

You might also like