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:

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

Happy Coding!
-cliff.