Running 2 Youtube Channel : The Masti Adda (Fun based ) : The Knowledge Adda (Knowledge based) : Subscribe for Knowledge with Fun....

Write a program to identify the even numbers from a series of 05 numbers and store them at another series.

Written by @
Apparatus Used: Microprocessor kit, Keyboards
Assumption: We have to write a program to identify even number form a series of 05 numbers starting 2200 H and store them as another series starting from 2300 H.
Algorithm:
  • Set the counter as number of byte.
  • Initialize Source as HL Pair.
  • Initialize destination as DE Pair.
  • Move first number in accumulator.
  • Rotate accumulator right with carry
  • Check for even number, if the number is even
  • Store at this number at destination and so on.
  • Increment the pointer for source as well as destination.
  • Decrement the counter and repeat until counter is zero.
  • End the program
Program:
Memory Add
Mnemonics
Op-code
Comments
2000
MVI
C, 05 H
Set the counter (05 number)
2002
LXI
H, 2200 H
Initialize source pointer
2005
LXI
D, 2300 H
Initialize destination pointer
2008
MOV
A,M
Move source data in accumulator
2009
RAR
Rotate accumulator right with carry
200A
JC
2010
If it is odd ,do not store
200D
MOV
A,M
If the no. is even, move the no. in Acc
200E
STAX
D
Store the no. at destination
200F
INX
D
Increase the destination pointer
2010
INX
H
Increase the source  pointer
2011
DCR
C
Decrement the counter by 1
2012
JNZ
2008
Repeat until counter is zero
2015
RST
5
Set Breakpoint
2016
END
End the program

Description of used instruction:
MVI: This instruction is used to store 8 bit data in specified register.
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV: This instruction is used to copy the content from source register to destination register.
INX: This instruction is used to increment the content of specified register pair by one.
DCR: This instruction is used decrement the content of specified register by 1.
JC: Jump if carry at to the target address.
RAR: Rotate accumulator right through carry.
JNZ: If result is not zero it will jump to the target address.
STAX: The contents of accumulator are copied into memory location specified by whose address specified by BC or DE register pair.
RST 5: This instruction is used to set break-point for the execution.
END: This instruction is used to execute the program.
 
Result:
Input: 2200-10, 2201-01, 2202-03, 2203-04, 2204-08
Output: 2300-10, 2301-04, 2302-08
 
Procedure to look output
· After press ENTER, You will get first screen
· Press G and Provide Initial address (as 2000)
· Press SHIFT+4,You will get first screen again
· Press M and Provide Input location for Input (M2200)
· Press ENTER and Provide your Input at location (2200:10)
· Press ENTER and Provide your Input at location (2201:01)
· Press SHIFT+4
· Press G and Provide Initial address (as 2000)
· Press SHIFT+4,You will get first screen again
· Press M and Provide address for output (M2300) and press ENTER
· You will get your desired output.

No comments:

Post a Comment