QuestionQuestion

Binomial Coefficients Program Requirements

Write an assembly language program and create an accompanying problem document.

Program Requirements

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
etc.

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.


Sample Output

Please enter an integer: 3
1 3 3 1
Please enter an integer: 4
1 4 6 4 1
Please enter an integer: 0
Bye!

Problem Document

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.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Pseudo-code:

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;

else return
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

clear screen;

enter integer loop:
print “enter integer” message;
read integer;
test if the integer equals 0; if true then go to exit;
save integer;
initialize counter variable with 0 value;

binomial loop:
test if counter is greater than the integer value; if true then go to the enter integer loop start;
call binomial procedure (integer, counter);
print result;
increment counter variable;
go to the binomial loop start;

exit:
print “bye” message;
end;...
$125.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats