Fall 2020

Tue Oct 27 - context, some bits & bytes, some machine code

I have to leave at 3pm today. I can meet later tonight, say 8pm, with anyone who has more questions or want's to talk about anything.

Questions ?


bits & bytes

some C

int a[5] = {10, 11, 12, 13, 14}; // NOTE : can only use {} in declarations.
int c[5];
int* b;

printf(" a is %p \n", a);
printf(" &a[0] is %p \n", &a[0]);
printf(" a[0] is %d \n", a[0]);
printf(" *a is %d \n", *a);

printf(" c[0] is %d \n", c[0]);   // What will this do?
printf(" *b is %d \n", *b);       // what will this do?

c[0] = 100;      // Is this OK?  (Yes.)
*(c+1) = 200;    // What the heck is this ? (It's c[1] ... at what address?)

*b = 20;         // Is this OK?  (NO!!!)

b = malloc(200 * sizeof(int));     // memory allocate - "the heap" - runtime

Discuss ...

HW1 assignment

Due today.

For all of these homework exercises, use your own judgement as to how much to do and where to spend your time.

I'm trying to choose work that will help you understand the material. If it it's too much, do what you can; if it comes easily, do more. ;)

I've posted my answers that you can compare with your own or look for hints if you're stuck.


On Thursday I'll start in with the stuff in "machine prog" CMU lecture notes; therere are 4 of them (basics, control, procedures, data) that we'll want to have a handle on to do the bomb lab, one week from Friday.

Also by Thursday I'll have some exercises for next Tues night posted.


How much memory is a kilobyte really? A thousand bytes? Or do people mean 2*10 = 1024. How about a megabyte? Hmmm.

Quick quiz :

Another quick quiz :

powers of 2 to "just know"
  2**6  = 64
  2**8  = 256 (one byte)
  2**10 = 1024 /courses /fall2020 /systems /notes /oct27
last modified Mon October 26 2020 10:23 pm