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

Write an assembly language program to add two 8 bit numbers, output 8 bit number using memory location

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to add two 8 bit numbers which are stored at different memory location and output should 8 bit number and output should be store at another memory location.
Algorithm:
  • Initialize memory pointer
  • Move First Number into Accumulator
  • Get second Number using memory location
  • Now add first number and second number
  • Store output at another memory location
Program:
Memory Address
Op-code
Operand
Comments
2000
LXI
H,2050 H
Load  first number at 2050 H
2003
MOV
A,M
Move the first number into A
2004
INX
H
Get Second number
2005
ADD
M
Add first number and Second
2006
STA
2052 H
Store output at 2052
2009
RST
5
Set break-point to execution
200A
END

End the program
Used Instruction:
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV rd,M: This instruction copies data from the Memory to destination register.
INX: This instruction is used to increment the content of register pair by one.
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: 2050-08
            2051-05
Output: 2052-08+05=0D
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: 08)
  • Press ENTER and Provide your Second Input (2051 :05)
  • 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 (M2052) and press ENTER
  • You will get your desired output.