For this exam, you may use your textbook, the Internet, your notes and assignments, your brain, and divine guidance if available. You may not use other people. If you get stuck, talk to Jeff Ondich, but please don't talk to anyone else about the exam.
(12 points) Consider the following PDP8/E program.
*0200 CLA OSR DCA A LOOP, DCA N TAD A SNA HLT CLL RAL DCA A RAL TAD N JMP LOOP A, 0 N, 0
The following table shows the execution times for all of the PDP8/E instructions (not including op-code 6).
Execution times in micro-seconds for PDP8/E instructions -------------------------------------------------------- Addressing mode ------------------------------------------ Instruction Indirect with Type Direct Indirect auto-increment -------------------------------------------------------- AND 2.6 3.8 4.0 TAD 2.6 3.8 4.0 ISZ 2.6 3.8 4.0 DCA 2.6 3.8 4.0 JMS 2.6 3.8 4.0 JMP 1.2 2.4 2.6 Opcode 7 1.2 (addressing mode irrelevant) --------------------------------------------------------
And now, the questions. Assume throughout these questions that the switch register is set to octal 1357.
What does this program compute?
For how long does the program run?
How many instructions does the program execute?
Based on this program (and the 1357 input value), what is the PDP8's native MIPS rating?
If you consider the same program, but a different input value, would the native MIPS rating be the same or different? Explain.
(6 points)
Write a fragment of PDP8 code to clear the last 100 words of page 0. Try to make this code fragment short. Call your code "program A," even though it's not a complete program.
Now imagine a code fragment that consists of a CLA followed by 100 DCA statements, each of which clears one word on page 0. Call this program B.
By what factor is B's performance better than A's? Is the comparison fair?
(4 points) Suppose somebody came up with a hardware device for the PDP8 to do multiplication quickly, and the instruction set designers wanted to add a MUL instruction to the instruction set. Assuming that op-code 6 is all used up with I/O instructions, how could you add a multiplication instruction without changing any of the existing instructions? Describe both your MUL instruction's behavior and its binary representation.
(6 points) When we looked at the Intel assembly language produced by the compiler for a simple C++ program, we saw that the assembly version used both a frame pointer and a stack pointer to keep track of stack frames. That is, one register (the frame pointer) stored a pointer to the bottom of the current stack frame, and another register (the stack pointer) stored a pointer to the top of the current stack frame.
Why are both a stack pointer and a frame pointer necessary?
Why didn't you need to use a frame pointer in your PDP8 recursive program?
When an Intel assembly program calls a function, the old frame pointer gets stored on the stack, but the old stack pointer does not. Why?
(2 points) Who are Federico Faggin and Howard Aiken, and what importance did they have in the history of computer architecture?
(2 points) I just finished a book, and I'm not sure what to read next. Please give me a suggestion. Thanks.
(9 points) Consider the program stackframes.cpp. Compile it and run it. Then compile it with the command "g++ -S stackframes.cpp". This will create the (Intel) assembly language program stackframes.s, which you can examine to help you answer the following questions.
Where does the return address get stored when main calls dosomething?
As precisely as you can, explain where n, k, a, and b are stored. Though you will have other things to say, make sure to include an answer to this question: if any of them are stored in memory, in which order do they appear in memory?
In the first loop in dosomething, change the loop condition from "k < 4" to "k < 5", recompile, and rerun. How does the program's output change? Explain why.
If you change the 4 in "k < 4" in the first loop to something big enough, you can make the program produce a "segmentation fault". What's the smallest value that produces a segmentation fault? Why?
(4 points) Show how you can use the slt and bne/beq MIPS instructions to implement the pseudo-instruction ble.