CS208 Introduction to Computer Systems Monday, 10 November 2025 + Coming up - Exam Monday, Nov 17 - see study notes below - we'll look closer at those notes Wednesday - Today: redirection, dup2, etc. - Wednesday/Friday - exam prep - simple networking in C + Questions so far? + files.c + redirect.c + pipe.c + Questions to think about - why are fork and exec separate? - why do you open a file instead of just reading and writing the file by name? - what is a file? - ... ===== some exam study notes ===== - Yet more memory - writing bytes as hexadecimal integers - byte order - what happens if you interpret a pointer to an array of char as a pointer to an int or an array of ints? - how do *, &, and -> work in their various contexts in C? - what's the difference between these two? char *p = "moose"; char p[6] = "moose"; - what does malloc do? what's the meaning of its return value? - what does free do? what's its return value [trick question]? - under what conditions would you malloc a chunk of memory instead of just declaring a big enough array? - How do the basic instructions work? - mov, test, cmp, jx, jmp, add, sub, mul, lea - call, ret - what are the purposes of the various special registers? - eflags - rip - rsp - rax - rdi, rsi, rdx, rcx, ... - sizes - rax vs. eax vs. ax vs. al - movq vs. movl vs. movw vs. movb - how do the addressing modes work? movl $1, %eax # immediate ($1) and register (%eax) movl $1, 0x604892 # direct (address is constant value) movl $1, (%rax) # indirect (address is in register %rax) movl $1, -24(%rbp) # indirect with displacement movl $1, 8(%rsp, %rdi, 4) # indirect with displacement and scaled-index movl $1, (%rax, %rcx, 8) # (special case scaled-index, displ assumed 0) movl $1, 0x8(, %rdx, 4) # (special case scaled-index, base assumed 0) movl $1, 0x4(%rax, %rcx) # (special case scaled-index, scale assumed 1) - What does an if-else look like in asm? - What does a loop look like in asm? - How does function-calling work in asm? - How to interpret the output of "objdump -d compiled-code" - gdb - interpreting an "examine memory" printout - si vs. ni - x/s vs. x/10wx vs. x/10bx vs. x/10gx - C and Unix and processes - what does the Unix command ps do? - what do these C functions do? - fork - execlp/execvp - wait - dup2 - what's a file descriptor? - what file descriptors are pre-initialized when you create a new process? - what is the point of dup2? - what is a pipe (on the command line)? - what is a pipe (in C code)? - Simple networking - what is a client? list some examples - what is a server? list some examples - what is a protocol? list some examples - what do socket, bind, listen, and accept do?