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

Write an assembly language program unpack the BCD Numbers.

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to unpack the BCD numbers is stored in memory locations 2200 H and we have to store output at memory location 2300 and 2301 H.
 
Algorithm:
  • Load data into accumulator
  • Mask the lower order nibble
  • Rotate Accumulator right without carry 4 times
  • Store the partial result
  • Load the original BCD digit
  • Mask higher byte nibble
  • Store output at memory location
  • End the Program
Program:
Memory Address
Op-code
Operand
Comments
2000
LDA
2200H
Load Packed Number in A
2003
ANI
F0H
Mask the lower order nibble
2005
RRC
Rotate A right without carry
2006
RRC
2007
RRC
2008
RRC
2009
STA
2300 H
Store the partial result
200C
LDA
2200 H
Load Number in accumulator
200F
ANI
0F H
Mask higher byte nibble
2011
STA
2301 H
Store the result
2014
RST
5
Set Break-point(optional)
2015
END
End the program
Used Instruction:
LDA address: Load data into register A (accumulator) directly from the address given within the instruction.
RRC: Each binary bit of the accumulator is rotated right by one. Bit D7 is placed in the position of B0 as well as carry flag.
ANI: This instruction logically ANDs the 8-bit data given in the instruction with the contents of accumulator and stores the result in the accumulator.
MOV: This instruction is used to copy the content from source register to destination register.
ADD: This instruction is used to add the content of specified register to the content of accumulator and store output in 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: 2200 H-31 H
Output:
2300 H-01 H
2301-03 H             
 
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:31)
  • 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