Feb 2
1. Discuss homework.
Feedback :
- This is technical - let's slow down and look at 'em.
2. Start chap 3?
My 2013 class notes :
There are powerpoint slides in the
CMU course
(see link at left).
Work through my gdb notes from 2013
and my assembler101 notes
And check out the cheatsheets on the
resources page.
---
Your mission is to be able to dissassemble short C programs and interpret the x86 assembly.
---
Things like ...
/*
* looking at a loop in x86 assembler
* (based on 05-machine-control lecture slides from
* http://www.cs.cmu.edu/afs/cs/academic/class/15213-f10/www/schedule.html)
*
* $ gcc -m32 -O1 -o loop loop.c
* $ ./loop
* There are 5 bits that are 1 in 0x4321 .
*
* $ gdb loop
* (gdb) disas main
* (gdb) disas pcount
*
*/
#include <stdio.h>
int pcount(unsigned x){
int result = 0;
while (x){
result += x & 0x1;
x >>= 1;
}
return result;
}
int main(){
unsigned data = 0x4321;
int ones = pcount(data);
printf("There are %i bits that are 1 in 0x%x .\n", ones, data);
return 0;
}