Write an assembly language program and create an accompanying problem document.
Design a recursive procedure to calculate Binomial Coefficients.
The procedure should expect two arguments on the stack, and should return the answer in eax. Only eax may be altered by your procedure. If you use local storage, it must be allocated on the stack.
Binomial(4,2) should return 6
Binomial(3,0) should return 1
This procedure must be in a file by itself.
You must also create an application that allows the user to enter an integer. The program then must use the binomial coefficient procedure to calculate the coefficients of (a+b)n. These should be displayed on one line of output.
The program should repeat until 0 is entered.
Remember to document the program, as well as each procedure, as required by the CS370 Coding and Documentation Standards.
Please enter an integer: 3
1 3 3 1
Please enter an integer: 4
1 4 6 4 1
Please enter an integer: 0
The problem document will contain:
1. Pseudo-code algorithm(s) for main and the binomial procedures.
Do NOT mention the stack or registers in the pseudo code.
2. A test plan and results.
1) binomial procedure
if k equals 0 then return 1;
if k equals n then return 1;
if k is less than 0 then return 0;
if k is greater than n then return 0;
if n is less than 0 then return 0;
binomial procedure(n-1, k) + binomial procedure(n-1, k-1);
C code :
int binomial_coef(int n, int k)
if(k==0 || k==n) return 1;
if(k<0 || k>n || n<0) return 0;
return binomial_coef(n-1, k) + binomial_coef(n-1, k-1);
2) main procedure
enter integer loop:
print “enter integer” message;
test if the integer equals 0; if true then go to exit;
initialize counter variable with 0 value;
test if counter is greater than the integer value; if true then go to the enter integer loop start;
call binomial procedure (integer, counter);
increment counter variable;
go to the binomial loop start;
print “bye” message;
By purchasing this solution you'll be able to access the following files: