Lab 5
So far (most of) you have been implementing procedures by
branching/jumping to a target and branching/jumping back to
a designated return point. This makes routines not very general
(you can't easily call them from different places) and it results
in a very tangled and unreadable program (technically called
spaghetti).
This lab will require you to implement REAL procedures using
JAL and JR which may be safely called from anywhere in your program.
Also, you will be reimplementing solutions you've already worked
through, so you will be able to see the value of the improved procedural
calling method as a result.
Submit: procedures.mal, README
Files:
Problem: I have written a program, procedures.mal. It is only half-written.
I have done the easy part. In my slothen laziness, I have left all the
procedure calls unfinished, so that you can implement them for me. Your
assignment is:
a) Read through the posted program (procedures.mal) and a sample
output (procedures.out) and understand what each part
of the program is supposed to do.
b) Implement all of the unwritten procedures at the bottom
of the file. Because the procedures are not yet
finished, the program will not run in its current
state. You may wish to fill in the functions with
'stub' procedures to enable you to run and debug as
you work.
c) Document ALL your work. This means meaningful comments
in the code and a clear, concise README.
Notes/Requirements:
You MAY NOT change any of the main program. Your procedures must work
as called by my program.
Your integer input/output routines should be general - they should work
for values from -(2^31) to (2^31 - 1). For a check, you must implement
your functions to handle negative numbers!
It is not possible to compute a factorial on a negative number.
Therefore, your factorial and sum of factorial functions should print
error messages when you try to feed them negative values.
Collaboration is not allowed on this lab assignment!
Collaboration is not allowed on this lab assignment!
Evaluation: your lab tutor will assign one of following grades: check +, check, check -, 0
- For a 0, do nothing, or use geti or
puti.
- For a X, you must submit a fully functional program up to the
specifications listed in the program description.
- For a X+, you will need to submit a program worthy of a check, plus
you will need to implement the functions designated in procedures.mal as
X+ material. This will involve uncommenting the marked lines
of code in the main program (okay, so you'll have to change main
a little, but that's it!).
- Failure to implement any of the X procedures or a missing or bad
README _WILL_ result in a X- or 0 for the lab! It is advised
that you double-check your lab with a tutor before submitting to
make sure your program REALLY works!
Happy Coding!
-cliff.