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

Write an assembly language program for decimal subtraction of two 8 bit number and store output at 2503 H.

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program for decimal subtraction. In this case we have to use DAA instruction but it can be use only with addition instruction so for this we have add first number and 10’s complement of 2nd number, which gives our desired output and we have to store output at 2503.As Example we have to subtract 96D-38 D. For this we have to add 96D+ (-38D), it indicates 96+ 10’s complement of 38.
Algorithm:
  • Load Second number in memory location
  • Load 99 in accumulator for 9’s complement
  • Get 9’s Complement and By incrementing A ,get 10’s complement
  • Get First Number
  • Add first number and Second Number
  • Now convert it into decimal
  • Store output at given location
  • End the Program
 Program:

Used Instruction:
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MVI: This instruction is used to store 8 bit data in specified register.
SUB M: This instruction is used to subtract the content of memory from accumulator and store the result in accumulator.
INR: This instruction is used to increment the content of specified register by 1.
DCX: This instruction is used to Decrement the content of specified register pair by 1.
ADD: This instruction is used to add the content of specified register to accumulator and store output in accumulator.
DAA: If the value of low order four bits in the accumulator is greater then 9 or if auxiliary carry flag is set, the instruction adds 6 to the low order four bits. If the value of high order four bits in the accumulator is greater then 9 or if auxiliary carry flag is set, the instruction adds 6 to the high order four bits
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:
2501-96 D
2502-38 D
Output:
2503-61
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 (M2500)
  • Press ENTER and Provide your Input at location (2501:98)
  • Press ENTER and Provide your Second Input (2502:38)
  • 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 (M2503) and press ENTER
  • You will get your desired output.

No comments:

Post a Comment