CS250 Lab 8: Help Everybody Get 100% on the Final
Due Wednesday, March 20
One of the pleasures in life as a humble CS professor is the invention of novel midterm and final exam questions. For the next two labs, I wish to share this with all of you! So for lab 8, create a test question about assembly, of the form "What does the following program print out". The expected answer is to write out what would appear in a terminal after the program runs, similar to question 16 on the midterm. The next lab will be to analyze everyone else's program, and write out the expected output!
Guidelines for writing a good test question:
- Use only assembly instructions we've discussed in class
- Avoid esoteric knowledge. Obviously "esoteric" is a matter of opinion here, and my test questions could be questioned in this regard. But generally speaking, testing on common scenarios (e.g. use of memory that was part of a discarded stack frame) is better than esoteric scenarios (e.g. using memcpy to duplicate a class without calling a constructor). Code that wipes out a value in rdx using multiplication would be on the edge.
- Short is better than long, but doing something complicated in too few lines of code can be confusing.
- Anything not really important should be done in "normal" ways, where "normal" is defined as "what we've been doing in class examples". So for example, print using read, printf, puts, or a system call. fputs would thus be considered abnormal. If you're asking about something a little weird, make it be the only weird thing in the question.
- The question should be hard enough, but not too hard. If you didn't know assembly before this semester, it should be hard enough you'd have missed it a couple months ago, but easy enough you might get it right today. CS education isn't about checking off a bunch of learned skills. It's about learning to think about how computers work, a mental development rather than learning any particular set of facts. So write questions that'll require some thinking.
- Assume the question will be answered without a computer. So keep the math easy.
- If writing a loop question that produces output each iteration, run enough iterations but not too many. I stick to 5 or so.
- If the output is an error, give at least the type of error, maybe some debugging information depending on the question. If it runs, identify that it runs, because otherwise everyone is left wondering.
My plan is to create lab 9 as a follow-up to this, and post it just before Spring Break, with a due date after Spring Break. Next week, we'll not have a lab assignment, just project 2.
Example Question
What is printed out by the following assembly program, which runs without any error? Hint: multiple lines will be printed.
.global main
.text
main:
mov $1, %r13
mov $10, %r14
foo:
add $3, %r13
add $1, %r14
mov $format, %rdi
mov %r13, %rsi
mov %r14, %rdx
mov $0, %rax
call printf
cmp %r13, %r14
jg foo
ret
format:
.asciz "%ld %ld\n"