Sunday, August 8, 2010

more programming, less starcraft

I sat down with my C studies for the first time in several days.

I'm really trying to internalize how things look in memory, and what happens when I declare variables and set values.

Like if I say:

int x = 5

the program (or compiler, I'm not sure which terminology is correct here) picks a spot in memory, and sets that spot in memory to 5. What I'm trying to internalize are the more complex notions of this. For example, if I have a computer where each address has one byte of memory, AND an integer on this computer is two bytes, then in memory I'd see:

Memory Location: 0000 0000
Memory Location +1: 0000 0101

So when I try to look at this variable or use it somehow, the program knows that it needs to take BOTH memory locations into account.

Asking for the value of x means the program has to start at the memory address it lives at, and take that byte and the next as well.

I think stuff like this is super important to internalize because not all computers/compilers are the same, and when you work with microprocessors those details are likely very important.

No comments:

Post a Comment