Lab #2: PC-231 Assembly Language Exercises

Assigned: Thu 24 Jan 2002
Due: Thu 31 Jan 2002

This lab consists of a number of exercises involving programming the PC-231 computer as described in lecture and in the PC-231 Computer Supplement. Although there is not a lot of documentation on the assembler and simulator programs, I have demonstrated them in lecture. (The little bit of documentation there is occurs at the bottom of the aforementioned supplement.)

Contents


Exercise #1: Sum of two decimal inputs

Write a short program which will read in two decimal inputs and print out their sum, in decimal.

Your program should be written in assembly language and should follow the format of the examples given in class and in the sample programs directory.

PLEASE NOTE:

I seem to be getting a lot of traffic at this site lately, even though this class is officially off the books. A lot of people seem to be reading this page, clicking on the link above, and then registering a "complaint" via our "Page not found" system to the effect that the target page is no longer available.

While I'm flattered that so many people are interested in my work, the e-mails are rather annoying, especially since I don't know where they're coming from (and I sometimes get as many 3 messages per day).

I might be willing to make the material available if I knew who was looking at it and why. So, if you are interested, please let me know who you are and how you got to my page (e.g., google search, fixed link from some other page, etc.). If you're here looking for solutions to homework problems for some other class, by the way, you'd probably be disappointed anyway, since the material here is written in an assembly language I cooked up myself: it's idiosyncratic, not very sophisticated and probably 40 years out of date, technologically speaking (in all fairness, the same might be said of me).

-- Fritz Ruehr [fruehr@willamette.edu]


Exercise #2: Minimum of two decimal inputs

Write a short program which will read in two decimal inputs and print out the smaller of the two, in decimal.


Exercise #3: Sum of a series of inputs

Write a program which will read in decimal inputs repeatedly until a zero value is read; at this point, it should print out the sum of the numbers read in so far (you may optionally include the final zero in the sum : ) ).


Exercise #4: Print your own name (with a loop)

Write a program which will print out your own name in ASCII format (of course, using the simulator, it will only come out one letter at a time, so it won't look very pretty). You can use device AD for ASCII output.

Your program should use a loop and a null-terminated "string" (i.e., a data section with successive ASCII char CONSTs). See lecture for a sample of this technique.


Exercise #5: Product of two decimal inputs

Write a program which will read in two numbers in decimal format, then multiply them together, and finally print out the result (in decimal). Think about the best way to do this: one obvious method is repeated addition (but this is slow). Another is the "add-and-shift" loop, in which you use the binary digits of one number to control additions of a shfted version of the other number into a running total; this is essentially the same algorithm you use when multiplying numbers by hand in decimal.

(See this drawing for hints on the "add-and-shift" approach.)