0% found this document useful (0 votes)
9 views1 page

CS II-Program 11

The document describes a program that counts the number of odd and even numbers stored in memory locations from 2031H to 2025H. The program initializes registers, loops through the memory block, increments counters for odd and even numbers, and stores the results in memory after the block.

Uploaded by

vinodnachane123
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 views1 page

CS II-Program 11

The document describes a program that counts the number of odd and even numbers stored in memory locations from 2031H to 2025H. The program initializes registers, loops through the memory block, increments counters for odd and even numbers, and stores the results in memory after the block.

Uploaded by

vinodnachane123
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/ 1

Program 11:

Aim: A block of data is stored in memory location from 2031H to 2025H. Write a program to
find the number of ODD as well as EVEN number from this block store the result immediately
after the end of block.

PROGRAM
Mnemonics
Address Label Opcode Operand Hexacode Comment
2000 START LXI H, 2020 21 Initialize HL with 2020
2001 20 Lower address byte
2002 20 upper address byte
2003 XRA A AF Clear A register to Zero
2004 MVI B, 05H 06 move 05 to C register
2005 05
2006 MVI C, 00H 0E move 00 to C register
2007 00
2008 MVI D, 00H 16 Move 00 to D register
2009 00
200A AGAIN MOV A, M 7E Move memory data to Accumulator
Rotate content of A REGISTER TO RIGHT
200B RAR IF BY ONE
200C JNC DOWN (2013) 02 Go to label DOWN
200D 13 Lower address byte
200E 20 upper address byte
200F INR C 0C Increament C by 1
2010 JMP EVEN (2014) C3 jump on label EVEN
2011 14 Lower address byte
2012 20 upper address byte
2013 DOWN INR D 14 increament D by 1
2014 EVEN INX D 23
2015 DCR H 05 decreament HL by 1
2016 JNZ AGAIN C2 jump on label Again if zero flag is not set
2017 0A Lower address byte
2018 20 upper address byte
2019 LXI H, 2025 21 load memory data to HL register
201A 25 Lower address byte
201B 20 upper address byte
201C MOV M, C 71 Move C register data to memory
201D INX H 23 increament HL by 1
201E MOV M, D 72 Move D register data to memory
201F STOP RST 1 CF Stop program execution

OUTPUT
Before execution After Execution
Memory loaction Data Memory loaction Data
2020 05 2025 02(Odd)
2021 02 2026 03(Even)
2022 04
2023 03
2024 06

You might also like