Computer memory architecture


In this section, we’ll look at computer memory architecture, a sub-section of computer architecture. 


ROM, Base RAM, and Extended RAM


When we think of computer memory it’s very common to think of RAM on its own. However, there are many types of memory that have different uses and ROM, Base RAM and extended RAM are examples of this.

ROM, short for read-only memory, is memory used to store things intended to be read but never overwritten. This is useful for storing crucial parts of the machine like the BIOS. Certain versions of ROM can be written to again once the memory has been removed and erased. ROM is not as expensive as RAM and retains its information permanently meaning the machine can be powered down and when it is powered back up the ROM will still be holding its information. Unfortunately ROM tends to have a much smaller storage capacity than RAM.

Base RAM and extended RAM are both forms of Random Access Memory which are a very fast type of memory but also quite expensive and as they are volatile forms of memory it means they don’t retain the information when the machine is powered down. Base RAM refers directly to the initial amount of RAM the machine comes with for instance 256MB. The initial amount of RAM the machine comes with can be greatly increased through various means one of which is known as extended RAM. With extended RAM, there are different standards capable of increasing the capacity to different amounts. The standard capable of increasing this the most is x86-64 which can increase the addressable memory to 256TB. One downfall of extended memory is that the software must be running in protected mode to use it.


Data, Address, Pointer, and Flag registers


Registers are small memory locations within the control unit of a CPU. There are several types of registers, for instance, the data register acts as a middleman between the RAM and the processor holding the data or instruction that has been fetched from the RAM to be used by the processor or else holding the data or instruction that is ready to be stored into the RAM.

While the data register holds the actual data or instruction to be fetched or stored from the memory the address register holds the memory location of the next piece of data or instruction that is either going to be fetched or stored.

Flag registers are updated automatically after mathematical operations and indicate the processor’s current state. The different types of flags used as indicators make it possible to determine the result of the mathematical operation. There are two categories that these different types of flags can fall under and these are conditional flags and control flags.

Finally, the pointer registers contain information relating to different memory addresses which ‘point’ to the required location. For instance, a stack pointer will contain the address of the last object to enter the stack while a base pointer would contain the address of the first object to enter the stack.


Bit, Byte, and Word


A bit, also known as a binary digit, is a single number. This number must either be a 1 or a 0. These bits, or ones and zeros, on their own are signals that can represent true or false, on or off etc. Using bits on their own you’re pretty much limited to using them as switches. However, by using bits in larger groups more becomes possible. For instance, a byte is a group of 8 bits and with 8 bits we can now represent significantly more than the simple 2 options we had previously. For instance, if we were representing numbers using bytes instead of only being able to represent a 1 or a 0 like we can with a bit on its own we can now represent 256 different numbers as this is how many different combinations of ones and zeros we can make with 8 bits in a byte.


  • 00000000
  • (And everything in between)
  • 11111111


A word is a unit of measurement used to represent the number of bits that machine’s CPU can handle in a single go. As computer architecture varies with each manufacturer and model the number of bits the CPU can handle in one go also varies. If a CPU has 16-bit registers and a 16-bit instruction set then a word, in this case, would be 16 bits. If a CPU has 32-bit registers and a 32-bit instruction set then a word, in this case, would be 32 bits. Finally, if a CPU has 64-bit registers and a 64-bit instruction set then a word, in this case, would be 64 bits.


Advantages and disadvantages of moving from 32-bit architecture to 64-bit architecture


Initially, the cons of moving from 32-bit architecture to 64-bit architectures far outweighed the pros meaning many people were very reluctant to transition over to the new 64-bit architecture.

At the time 32-bit architecture had been dominant for a long time thanks to its backward compatibility with 16-bit meaning it could work with all the programs that had originally been designed for 16-bit architecture but much faster as 32-bit architecture can handle twice as many bits at a time and the larger registers meant many more memory locations were now available.

Then 64-bit architecture came along and it wasn’t backward compatible meaning everything that had been designed to work with either 16-bit or 32-bit architecture wouldn’t work effectively removing access to a lot of programs that many people had come to rely on. While the 64-bit architecture could handle more bits at a time and had access to many more memory locations the lack of backward compatibility meant the transition just didn’t make sense for a lot of people. In fact, Intel had to add an emulator that could translate 32-bit programs into 64-bit to create the backward compatibility people wanted. Unfortunately, this translation was too slow to make it practical so instead of having a purely 64-bit architecture Intel decided to adopt the architecture that AMD had developed which is standard 32-bit architecture but with extra 64-bit registers added to overcome the natural memory limit you got with the original purely 32-bit architecture.


Stacks and Queues


Stacks and queues are two different types of data structures and both of them are used to store and organize data objects in different ways. The term stack refers to a container of data objects and is processed using the LIFO principle also known as the last in first out principle. When adding to a stack you can only ‘push’ onto the top of the stack which ‘pushes’ each existing object down in the stack. When removing from a stack you can only ‘pop’ the top object off the stack. As only the top object can be removed and the last object to be added to the stack is always at the top it fits the last in first out principle. In the LIFO principle, the stack pointer would indicate the address of the last object into the stack meaning it also indicates the address of the first object out of the stack.

A queue is also a container of objects except that unlike a stack a queue is processed sequentially in order of arrival. This means that whichever object enters the queue first is also the first to be processed and removed. Think of it like a queue of people at the post office. The person at the front of the queue will be seen before the person at the back of the queue. This process is referred to as the FIFO principle or the first in first out principle. In a queue using the FIFO principle, there needs to be a pointer to the first object into the queue but also a separate pointer for the first object out of the queue as the addresses would not be the same as they would in a stack.


Using a queue to reverse stack order

The process of reversing the order of a stack using a queue is a simple one. As a stack uses the LIFO method it naturally offloads in reverse order to what it was loaded. If this is put into a queue which uses the FIFO method then the empty stack can then be loaded up from the output of the queue and the stack is now in the reverse order. See example below using the word ‘help’.

  1. The word ‘help’ is loaded into a stack one letter at a time and so is now stacked like so:
  2. The stack is now emptied into the queue using the FIFO principle so the word is now queued like so:
    P L E H
  3. The queue is emptied back into the stack using the FIFO principle so the stack is now stacked as so:


As you can see the order of the stack has been reversed using a queue.


Stack overflow


Stack overflow is something that occurs when the limited amount of address space in a call stack is exceeded. If a program tries to access more memory than the call stack allows then this is referred to as stack overflow and when this happens it usually means the program crashes. One of the main causes of stack overflow is usually an issue with the program’s recursion. Either it loops indefinitely, or too many times to complete and on each recursion more space is taken up until the allowance is exceeded. One way of achieving this would be to create and call a function that then calls itself. This infinite loop could potentially result in stack overflow although some compilers are designed to be able to cope with this specific type of recursion.