CS 353 -- Fall 06 -- Lab 5: Writing PC-231 Programs
---------------------------------------------------
Write up programs in PC-231 assembly language to solve the following problems.
Try to use comments, if for no other reason to show that you understand how the
assembler handles them (remember, you'll be writing an assembler of your own soon).
You should be able to access the assembler (asm231) and simulator (sim231) using
your hydra unix account (run "telnet hydra" from the Windows Start menu, use "un"
to get out of the menu system if necessary, then issue the asm231 or sim231 commands
as shown in class). You can keep your program in an editor window and just paste
it in after changes (remember to use "Control-D" to signal end of input).
----
1. Read in 5 numbers (in decimal) and print out the minimum (first) and
maximum (second) values, again in decimal. You may assume all the numbers
are non-negative, if that helps. (You might start off with two numbers,
then three, before you generalize to five.)
----
2. Read in 15 letters (in ASCII) and print them out in reverse order. You will
need to save and retrieve them in RAM, using the LOAD and STORE operations.
Look at the sample programs (e.g., the one which writes out a string from RAM)
for ideas on how to do this. Note that you will *not* need to store the
characters as part of the "program" using CONST pseudo-instructions, since
you will be reading them in from input.
----
3. Read in a decimal integer n representing the order of a polynomial (e.g., 2
for a quadratic), then read in n+1 coefficents (some of these might be 0).
Finally, repeatedly read in numbers to be used for the value of the "unknown"
(x) in the polynomial, and print out the value of the polynomial as a whole.
Stop the program when a 0 value is given for the unknown.
For example, if you read in 2, then 3 4 5, your polynomial is:
3x^2 + 4x + 5
and its value at various x's is:
1 => 12
2 => 25
3 => 44
4 => 69
0 => stop the program
NOTE: you should use as efficient a method as possible for evaluation of your
polynomial: work from left to right, multiplying by x and adding the next
coefficient as you go.
NOTE: this is partly a test of your ability to sketch out a program with several
loops and "function calls" (for the multiplication), so draw flowcharts or
write pseudo-code first.
----
4. Read in a string of ASCII letters (you don't have to check that they *are*
letters), terminated by a period ('.') and use bubble sort to sort them
in increasing order. (If you use mixed cases in your input, the ASCII values
of all the uppercase letters are lower than the lowercase ones, so you'll
see the capitals first.)
----