This is a an exam. You may consult your notes, any book, and the Internet. You may not speak with any person other than Jeff Ondich, electronically or otherwise, about the content of this exam. If you obtain relevant information from any source other than yourself, cite your sources clearly. Justify your answers. (Note that "justify your answers" implies "show your work.") Have fun.
Numbers (10 points)
(5 points) Sometimes you want to write code that behaves like this pseudo-code:
if A < B do X else if A > B do Y else do Z
Assuming X, Y, and Z are unknown-length blocks of code, write PAL code implementing this if/else-if/else structure. You may assume that the whole thing, include the locations A and B, fits on a single page. You can just write "[X goes here]" or something similar to indicate where X, Y, and Z appear in your code.
(6 points) Consider the following story about D latches and flip-flops.
Assuming there was a long enough pause between each step to enable the whole circuit to stabilize, draw a timing diagram for this story for each of the following:
(6 points) Consider the following boolean function of three variables:
A B C | Out ================= 0 0 0 | 1 0 0 1 | 1 0 1 0 | 0 0 1 1 | 1 1 0 0 | 1 1 0 1 | 0 1 1 0 | 1 1 1 1 | 0
(2 points) I just finished a book (Our Kind of Traitor, by John LeCarré--quite good, as he usually is). What should I read next?
(7 points) Assembly language in its purest form has the property that each assembly instruction corresponds to exactly one machine/binary instruction. The PAL language as you have learned it has this property (e.g. "TAD 0007" corresponds to "1007", etc.). Even with that level of purity, however, the designers of the PAL assembler "pal" have seen fit to give programmers a little extra help, by providing assembler directives (e.g. *0200), comments, etc.
Another kind of help assembler writers sometimes provide is called a "pseudo-instruction" (see pages 140-141 of the textbook). A pseudo-instruction typically corresponds not to a single machine instruction, but to a sequence of instructions. The assembly language programmer will use the pseudo-instruction in a program just like any other instruction, but when the assembler runs (e.g. "pal -r myprogram.pal"), the pseudo-instruction gets transformed into two or more machine instructions instead of just one. The programmer, for most purposes, never has to know the difference. (Or course, as with any programming knowledge, knowing how a thing works makes debugging and performance-tuning easier, so it's good to know which instructions are pseudo and which aren't.)
If I were about to embark on a major PDP-8 programming project and I wanted to give myself and my teammates some help, I think the thing I would desire most urgently would be a second accumulator. Since I'm not going to modify the PDP-8 hardware (I'm terrible with a soldering iron), I could modify the PAL assembler instead, to simulate a second accumulator. I would, for example, provide myself with instructions like CLA2, TAD2, DCA2, etc.
Your job for this problem is to explain in detail how you would go about modifying the pal program to simulate a second accumulator. You'll need to explain where the contents of AC2 get stored, what instruction sequences TAD2 and DCA2 get transformed into, what additional restrictions this new stuff will place on PAL programmers, and so on. The goal is to give me as a PAL programmer access to a simulated accumulator AC2. How would you go about giving me that?