CS 352 TA Homepage
Welcome to my brief homepage for CS 352. Announcements, homework hints,
etc. may appear here.
The weekly discussion session occurs on Wednesday from 3-4 PM in
Painter 3.20. We introduce homework problems and labs, discuss
questions from you (the students), and review test material. It is to
your advantage to look at the homework ahead of time so you can ask good
questions. It is to your disadvantage to wait until the last minute and
rely on me to address your issue.
My office hours consist of Monday 10-10:50 on the 20th floor of the tower
and the Wednesday discussion session. Please feel free to contact me and
setup an additional meeting time if your schedule requires it or you need
some random help. I am more pleased to help you when you have started
ahead of time, but I'm around to help, so ask anyway.
The class website is:
http://www.cs.utexas.edu/users/hunt/class/2006-fall/cs352/cs352.html
Goto
http://www.utexas.edu/its/usenet/extnews for information on accessing
the newsgroup: utexas.class.cs352-hunt.
Homework Solutions
Discussion Notes
Test #4 (Final)
*Correction*
Date/Time: Tuesday, December 19, 9AM - 12
Noon
Location: PAI 3.14
Review Sheet
Test #3
Review Sheet
Homework #8 Hints
This assignment is relatively straightforward.
- 5.11:
- Part A -- this is like slide 10 from "Class 10" notes
(class11.pdf).
- Part B -- remember that sum accumulates the answer.
- Part C -- you *must* assume that there are only two integer
functional units.
- Part D -- you can assume similar assembly, and that there are two
floating point functional units.
- 5.14: You can assume it takes four cycles to do an integer
multiplication, and that you have two integer functional units.
- 5.15: You can probably compile this to assembly using GCC and then
modify the assembly to use the conditional move instruction.
- 5.16: What question does this remind you of? It reminds me of
3.32.
Homework #7 Hints
Here's a skeleton for one way of doing 64 bit multiplication. I have a
complete version that does work, so it should be helpful. Feel free to
send suggestions.64bit-mult.c
Test #2
Review Sheet
Lab #2 Hints
- Look at page 259 in the textbook to see how instructions are laid out.
- Page 261 has branch encodings and register numberings.
- Print a copy of the slides from class 11. Double-sided, two slides
per page requires carrying 8 sheets of paper around. I find slide 7
particularly useful when I forget which register is subtracted from the
other. Slides
- Your solutions are expected to follow the X86 register usage
conventions (AFAIK the Y86 adopts these conventions). See page 173 for
an explanation of usage conventions.
- How can you access the carry out from an addition? We were initially
thinking you could use one of the conditional jumps, but after thinking
about it, it seems harder than that. The code from lab1, section addOK,
should help. You can and 0x80000000 with each lower word to get the MSB
of that word. Then it's just a matter of figuring out what sign
beginnings and changes means a carryout occurred.
Homework #6 Hints
Dr. Hunt does a good job describing the problem. Partial credit may be
awarded, but you're going to be in much better shape if you actually get it
to work. It takes the grader 3 minutes to grade something that works as
expected and 15-60 minutes to grade something messed up.
Homework #5 Hints
- 4.32: Like the question says, use figure 4.16 as a guide.
- 4.33: Look for the 6 stages that describe how rrmovl and popl are
implemented and combine them. It's cool that you're going to learn how
leave works.
Homework #4 Hints
- 3.34: Do this problem in two steps:
- Figure out what each switch statement does
- Figure out which case is associated with which spot in memory
Remember: cases can "fall through" to the next case.
- 3.35: This problem is a brain teaser. You will earn credit if you
have one less memory access from within the loop.
- 3.36: You can figure out what types a_struct contains by examining n. 4 *
5 equals 20.
-
3.38: This problem is no longer doable since the department's Linux
machines randomize the beginning of the stack location. As such,
Dr. Hunt and I have decided to not assign the problem as written.
However, if you do something that demonstrates you understand the
stack, how buffers allocated on the stack interact with return
addresses, etc., then you can earn some "extra credit." The
information must be directly related to a buffer overflow attack. I
have no idea how much extra credit you can earn, but it will be more
than 0% and less than 20%. It depends on the quality.
- 3.39: Start reading at the bottom of page 226. Keep going through
page 229. After you do this five times, the answer should be pretty
apparent. Have confidence!
Lab #1 Hints
Test #1
Review Sheet
Homework 3 Notes
Question Disambiguation
- 3.31: Compile with optimization level 3. Note that if you try to
generate an executable you will get a "main doesn't exit" error. Use the
command:
gcc -O3 -S 3.31.c
My assembly for the solution looks as follows:
.file "3.31.c"
.text
.p2align 4,,15
.globl decode
.type decode, @function
decode:
pushl %ebp
movl %esp, %ebp
movl 16(%ebp), %ecx
movl 12(%ebp), %eax
subl %ecx, %eax
movl 8(%ebp), %ecx
popl %ebp
imull %eax, %ecx
sall $31, %eax
sarl $31, %eax
xorl %ecx, %eax
ret
.size decode, .-decode
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.3.4"
Discussion Example Source Discussion Example Assembly
- 3.32: (A)'s simple after you think about it. Part (B) is slightly
vague, but if you think about it, you'll discover the answer. Part (C)
requires that you understand how
goto's work. Example with goto. Part (D) asks about the
use of this strategy in general. Why is it safe to use the strategy in
this example? What would make this strategy unsafe?
- 3.33: Remember that
%eax is the return value in the
IA-32 specification. If you don't see a jump, then did the case
statement "fall through?" Discussion example
source
- 3.37: Note that terminals and the C standard IO library will buffer
input by default. The simplest solution involves
getchar
and
putchar.
If you want to challenge your knowledge of C, use
fgets and
puts. If
you use these, use a buffer of size 8 bytes (for easy testing). If
your program is vulnerable to buffer overflow attacks, you will lose
points.
Homework 2 Notes
- Floating Point Tip: Learn the meaning of Mantissa/Significand,
Exponent, Bias, and Sign bit ahead of time. Refer to figure 2.23 (page
86) and practice problem 2.33 (page 87).
- An easy way to get xFF...FF on a w-bit machine is with the
C-expression ~x0.
- Since problem 2.57 is the most abstract, do it last
Question Disambiguation
- 2.50: Here is an example solution for K = 3:
(x << 1) + x
- 2.51: An example bit sequence for part (A) where w=16 and k=3: 1111
1111 1111 1000. You can assume to be working with a value of type
"signed int", with the understanding that the width of the "signed int"
will vary. It could be 39 for all you know.
- 2.52: Think about using masks and shifts. You may not reference w
since it is not a parameter to the function.
Hint: Suppose you
are given i == 2. Could you get the value 0x00FF0000 by logically
shifting xFF left? What operation can you apply to x00FF0000 to give you
another value that does not depend on w?
- 2.53: Pretend you have two different architectures. One of these
architectures provides a logical right shift but not an arithmetic right
shift. The other provides an arithmetic right shift but not a logical
right shift. Implement the missing operation for each of these
architectures.
- 2.54: These are tautology questions (like in 313k). Look at slide 40
of the Integers lecture for some related puzzles.
2.55: When you represent 1/3, k = 2, because "01" repeats
infinitely. When you represent 1/5, k = 4, because "0011" repeats
infinitely.
The author gives a hint in English by suggesting
shifting x by k. So here's my extension of that
hint: What is x >> k equal to? X / expt (2,
k). You'll find a variation of this useful for solving parts A
and B of the homework. Use part B to test your solution to part
A.
- 2.56: There are four cases to consider. Use the standard bit and
boolean operators. "|" is an example of a bit operator. "||" is an
example of a Boolean operator.
- 2.57: Learn how a 32 bit floating point representation works. Then
try (A), (B), and (C) in the IEEE 32-bit floating format. After you have
an idea how these numbers are represented, generalize to the variables
given in the question.
- 2.59: Do practice problem 2.33 on page 87 before doing this.
- 2.61: This is easy once you understand how denormalized values,
normalized values, 0, infinite, and NaN are represented in floating
point. Do not attempt this before doing practice problem 2.33.
Homework 1 Notes
Question Disambiguation
Obviously, for any question that asks you to write code, you have to
turn in a printout of the code.
- 2.38: You must run the code on a little endian and big endian
architecture.
- 2.39: You must execute the code on 2 different data types. I
recommend choosing three or more of the following: int, long, float,
double, string. One platform that provides an interesting result (little
endian) will suffice.
- 2.40: Look at figure 2.3. Copy and modify the code to create
functions show_short, show_long, and show_double. Technically the
question asks for more than one machine type, but for me you will earn
credit if you do it on an interesting architecture (little endian).
- 2.41: You may want to print 1 sample execution of your program on a
little endian machine. Print the code too.
- 2.45: Printing the test cases reduces the chance of my making a
mistake against you while grading your paper. If you print, I may give
you the benefit of the doubt. If you don't print evidence, I may not
give you the benefit of the doubt. It depends on how clear your code is
and how smart I am at the time of grading.
- 2.48: There are two ways to earn credit. (1) Give me a full
mathematical proof. (2) Do a proof by cases using for the 4-bit 2's
compliment number system. This is less than a complete proof but good
enough for me.
- Fibonacci: I prefer you calculate the MIPs for otto.cs.utexas.edu,
but you can definitely earn full credit if you do it on a different
machine.
Related Links
- C/C++ Standard I/O
Reference You can access these functions by adding
#include
<stdio.h> at the top of your file.
- Here's the proper signature for main, and an
example use of atoi.
-
GDB Quick Reference Card
- Install Cygwin and X Server. You can use these to ssh into the
Taylor Linux machines and run emacs/vim and your other favorite
applications remotely.
Setup Instructions
- Seemingly cool C reference page link
Tips for Responsive Email Communication
- ALWAYS begin your subject line with "CS 352:", "[CS 352]", or
"CS 352 - ".
- If your email requires action (for example, a reply), place the words
"- followup required" at the end of your subject.
- Formulate your facts and question clearly. It's easier to address a
concern that's clearly stated than a mess of words that wander only to
arrive at half a question.
- Use capital letters to being sentences. Write in complete
sentences.
- Address your professors that hold Ph.D. degrees as Dr. ___ and your
professors that don't either as Mr. ___ or Professor ___.
Home