CS208, Friday 28 Jan 2022
Miscellany
- Please change your Carleton password no later than Feb 6.
- A request from me to anybody in the room who's fired up about blockchain
- One picture of Maisie, as requested by more than one of you.
In-class exam, Wed Feb 2
- General info
- Closed-everything-except-your-brain
- In Olin 304/306
- If you have official accommodations related to test-taking conditions, I'd be grateful for a reminder before Wednesday
- If you won't be able to attend due to COVID restrictions, let me know as soon as practical
- General topics
- data representation
- C
- x86 assembly basics
- My philosophy of in-class exams
- Stuff that I want you to have in your head, not just your notes
- Mostly "what" and "how", only a little bit of "why"
- No tricks
- I try not to make it long (occasionally, I screw this up, but mostly not)
- I indicate what I think is most important for you right now via classroom topics,
homework assignments, sample programs, and quizzes
- What to study
- homework assignments
- quiz
- sample code
- class notes
- backup reference material: textbook readings
- Types of questions
- Short answers
- Here's some code; what's the output?
- Write this tiny amount of code to do X
- That memory grid from the quiz
- Wildcard (I reserve the right to come up with a different type of question, but
see philosophy above)
- Integers
- binary/decimal/hexadecimal notation
- two's complement
- Characters
- difference between characters and C char
- codepoints vs. encodings
- UTF-8 encoding (with chart in hand)
- C types
- int vs. long
- char *p vs. char p[10]
- string literals: "Hello"
- char literals: 'A', '\0', '\', '\''
- sizeof (don't confuse with strlen!)
- C I/O (input/output)
- printf, %c, %s, %d, %x, %X
- fgets (including what if line is longer than buffer?)
- Null-terminated char strings
- printf %s vs. %p
- strlen
- strcpy vs. strncpy (including what if source is longer than buffer in strncpy)
- strcmp
- C pointers
- & as unary "address-of" operator
- * in type declarations
- * as unary operator for dereferencing
- assignment statements with pointers
- C bitwise operators
- ~ (not)
- & (and)
- | (or)
- ^ (exclusive or / xor)
- C stuff that's pretty much the same as Java
- if, else
- &&, ||, !
- while, for
- {}, ()
- +, -, / (int div), %
- function signatures
- Basics of x86_64 assembly
- registers (what are they?)
- mov, lea, add, sub, push, pop
- test, cmp
- j, js, jz, jl, jle
- call, ret
- how do you loop?
- how do you do if/else?
- how do you call a function?
Turning assembly back into C
- Some instructions to get straight
- cmp, test
- j, jl, je, jle, jz, js
- call, ret
- Draw a picture
- Experiment with Compiler Explorer: what do simple loops, simple if/else, etc. look like?
- What can we assume about the registers at the beginning of a function?
- What does a function call look like?
Let's try puzzle0