#write
an assembly
program to
calculate the value of 5P2. At
First write a ProC to Determine
the value of 5p2. use 120h as
Initial address
of Stack Segment
Store your result in register DL
Answers
Answer:
Now we will write another Assembly program to find nCr for given n and r
Let’s identify variables needed for this program.
First variables will be the one which will hold the value entered by user in the variable N and variable R.DIFF will hold Difference between N and R. In nCr N is always Greater than R so the difference will be N-R. NN variable will hold N!, RR variable will hold R! NR variable will hold (N-R)! FACT will hold 1H and Other variable RES will be holding the Resultant Decimal equivalent printable form to be printed for the User on Screen and Other variables will be holding the Messages “ENTER N: $”, “ENTER R: $”, “N > R (NOT ALLOWED) !!! $” and “RESULT : $” to be printed for the User, So in all Twelve variables.
The identified variables are N, R, DIFF, NN, RR,NR, FACT, RES, MSG1, MSG2, MSG3 and MSG4.
First Line – DATA SEGMENT
DATA SEGMENT is the starting point of the Data Segment in a Program and DATA is the name given to this segment and SEGMENT is the keyword for defining Segments, Where we can declare our variables.
Next Line – N DB ?
R DB ?
DIFF DB ?
NN DW ?
RR DW ?
NR DW ?
FACT DW 1H
RES DB 10 DUP (‘$’)
MSG1 DB “ENTER R : $”
MSG2 DB 10,13,”ENTER N : $”
MSG3 DB 10,13,”RESULT : $”
MSG4 DB 10,13,”N > R (NOT ALLOWED) !!! $”