CS208, Friday 21 Jan 2022
Coming up
- Monday assignment: bit operations & UTF-8
- Thursday assignment: questions about C & assembly language (posted by Monday)
- How does C get turned into assembly? assembly into machine?
- Debugging C programs with gdb
Questions?
Bitwise operations
- ~, &, |, ^, >>, <<
- | to turn a bit on
- & to turn a bit off ("masking")
-
and grabbing pieces of a bit pattern
- assembling the integer you want
x86_64 architecture
x86_64 simple programs
We can write some simple programs in x86_64 assembly language.
Here's a hello-world program, along with an explanation how to assemble and run it: hello.asm
Mostly, we won't be writing assembly language programs. Instead, we'll be reading the assembly language generated by the gcc compiler.
Plan
- Learn some x86_64 basics
- Write small C programs and compile them to assembly
- Study the relationship between high-level language constructs (e.g. function-calling and parameter-passing, allocation of space for local variables, etc.) and their corresponding assembly language code