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

Write an assembly language program pack the two unpacked BCD Numbers.

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to pack the two unpacked BCD numbers is stored in memory locations 2200 H and 2201 H and we have to store output at memory location 2300 H.
Algorithm:
  • Load MSB of data into accumulator
  • Adjust the position
  • Make LSB BCD digit to zero by ANDing operation
  • Store the partial result
  • Load the LSB BCD digit
  • Add the lower BCD digit
  • Store output at memory location
  • End the Program
Program:
Memory Address
Op-code
Operand
Comments
2000
LDA
2201 H
Get MSB BCD digit
2003
RLC


2004
RLC


2005
RLC


2006
RLC

Adjust the position
2007
ANI
F0H
Make LSB BCD digit zero
2009
MOV
C,A
Store the partial result
200A
LDA
2200 H
Get the lower BCD digit
200D
ADD
C
Add lower BCD digit
200E
MOV
A,C

200F
STA
2300 H
Store the result
2012
RST
5
Set Break-point(optional)
2013
END

End the program

 2nd Method
Memory Address
Op-code
Operand
Comments
2000
LDA
2201 H
Get LSB BCD digit
2003
MOV
B,A

2004
LDA
2202
Get MSB BCD digit
2007
RLC


2008
RLC

Adjust the position
2009
RLC


200A
RLC


200B
ORA
B

200C
STA
2300
Store the result
200F
RST
5

2010
END

End the Program
Used Instruction:
LDA address: Load data into register A (accumulator) directly from the address given within the instruction.
RLC: Each binary bit of the accumulator is rotated left 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.
ORA: The contents of the register are logically ORed with the contents of 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: 2200 H-04(LSB)
            2201 H-09(MSB)
Output: 2300 H-94             
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:04)
  • Press ENTER and Provide your Second Input (2201 :09)
  • 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.

1 comment:

  1. Anonymous25 July, 2014

    Whhy viewers still use to read news papers when inn this technological globe all is available on web?


    my web site: online education

    ReplyDelete