Understanding your Computer Memory and CPU
To be able to effectively program with low level programming languages such as assembly, it is important to understand how computers structure memory, and how data is processed by the CPU. Most modern computers work off what is referred to as Von Neumann architecture. In this type of architecture, the computer is divided up into two main components, memory, and the CPU. Data is read out of the memory, processed by the CPU, and stored back in memory.
We can think of computer memory like mailboxes. Each mailbox is associated with an address, and we can place data within each mailbox to be stored until it is required. When it is required, we access the address and take the data. We can then put it back inside either the same or different mailbox. The CPU is the component responsible for accessing, manipulating, and moving data. It can fetch instructions from memory one at a time and execute them. This is often referred to as a fetch-execute cycle.
Diving further into the CPU, there are a number of components that help the CPU access, manipulate, and move data. The CPU has a program counter, which tells the computer where to fetch the next instruction from. This instruction is then passed on to the instruction decoder, which figures out what the instruction actually means. This allows the CPU to know exactly which operation needs to be performed…