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 find smaller number between two numbers

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to find smaller number between two number and we have to store larger number at memory location.
Algorithm:
  • Get First Number and store it in accumulator
  • Get second Number
  • Compare first and second number
  • Check for the carry if carry generated then first number is greater otherwise second number will be greater
  • If first number is greater then move it into Accumulator otherwise store output.
Program:
Memory Address
Op-code
Operand
Comments
2000
LXI
H,2050 H
Store First Number
2003
MOV
A,M
Save in Accumulator
2004
INX
H
Get the 2nd number
2005
CMP
M
Compare First Number & 2nd
2006
JC
200A
Jump if carry
2009
MOV
A,M
Move number in accumulator
200A
STA
2052
Store larger number
200D
RST
5
Set Break-point
200E
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: This instruction is used to copy the content from source register to destination register.
INX: This instruction is used to increment the content of specified register pair by one.
CMP M: Compare data in memory with accumulator
JNC: Jump if not carry at specified memory address.
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-10, 2051-01
Output: 2052-01 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 (M2050)
  • Press ENTER and Provide your Input at location (2050:10)
  • Press ENTER and Provide your Input at location (2051:01)
  • 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.

No comments:

Post a Comment