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

Write a program to covert a hexadecimal number into two nibbles (unpacked).

Written by @
Apparatus Used: Microprocessor, Keyboards
Assumption: In this program we have to break a hexadecimal number into two nibble. Let number is stored at location 2050 and we have to store nibble at 2051 H and 2052 H.

Algorithm:
· Load the number into accumulator
· Clear the MS nibble and store it a location
· Load again the data into accumulator
· Clear the LS nibble and store it other location
· End the program

Program:
Memory Add
Mnemonics
Op-code
Comments
2000
LDA
2050 H
Load the number in accumulator
2003
ANI
0F
Mask off the MSB of the Number
2005
STA
2051 H
Store the partial result
2008
LDA
2050 H
Again load the number in accumulator
200B
ANI
F0
Mask off the LSB of the Number
200D
STA
2052 H
Store the other partial result
2010
RST
5
Set Breakpoint
2014
END

End the program

Description of used instruction:
LDA adr: Load data into register A (accumulator) directly from the address given within the instruction.
ANI: This instruction used to perform the AND operation between the given data and the accumulator.
STA: This instruction is used to store the content of accumulator at specified memory address.
RST 5: This instruction is used to set break-point for the execution.
END: This instruction is used to execute the program.

Result:
Input:
2050-AF
Output:
2051-0F
2052-A0

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 (M2050)
· Press ENTER and Provide your Input at location (2050:AF)
· 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 (M2051) and press ENTER
· You will get your desired output.

No comments:

Post a Comment