Skip to main content

Posts

Showing posts with the label program

The memory layout of a computer program and how a computer works.

A computer program that is loaded into a computer's RAM has a distinct layout. Before we dive into how a computer program looks in memory we need to understand what is the computer offering us when it comes to memory management. A computer's RAM memory is a long array of bits. Instead of reading and writing 1 bit at a time we read and write in chunks of 8 bits called bytes. If we want to read or write a location we need to know it's address. If our computer supports 32 bit addresses than we can work with:  2^32 = 4294967296 bytes which is 4294967296/1024=4194304 Kilo Bytes, which is 4194304/1024= 4096 Mega Bytes which is 4 Giga Bytes. Adresses start at 0 and go all the way to 2^32-1. You can think of a RAM memory as a long string of beads, each bead containing 8 bits. A computer program is composed out of data and instructions. Instructions tell the CPU what to do with data from memory. The only operations that a CPU does to data are mathematical/logical opera...