Skip to content

section4_memory

Fábio Gaspar edited this page Jan 11, 2019 · 1 revision

Computer memory organization

A program is a set of instructions. When you load a program, these structures and the data required by the program is loaded to some kind of memory. This memory is called RAM (Random Access Memory), which is a high speed volatile memory, i.e., when the computer is powered off, all the data stored in RAM is lost. Thus, RAM is only used to store temporary content.

Many programs need to store information temporarially, and that is done through RAM. Thus, it's important to have basic notions of how RAM works and it's organized.

Think of RAM as a set of sequencial boxes that hold binary digits, 0 and 1. Each of these little boxes are called bit, the basic memory unit.

For convenience, these little boxes are grouped on sets of eight. A set of 8 bits it's called a byte. When accessing RAM, you can't access a particular bit. Instead, you access bytes. These bytes, are labeled with a unique number, called the address, that starts from at and goes all the way up to a number that depends on the RAM size.

This means that in our C programs, the smallest memory block is 1 byte. We will see there are other data types that creates larger groups of bytes. Internally, everything is stored in binary, but the way we interpret data can change, which explains why we need some abstraction in programming languages to tell how the computer should process a set of binary information (is this a number? is this text? is this an image?).