BackReturn Home

Hardware & OS Basics

Part 1: Hardware

[Video Link]

The Main Components That Make Up A "Computer"

Central Processing Unit (CPU)
Memory (usually known as RAM, or Random Access Memory)
Input / Output (I/O)

All of these connect to the Motherboard (or Mainboard).

Almost all "computers" will have these components. The type of computer it is will be determined by its Form Factor (i.e.: size and shape) and our Performance Needs (i.e.: what we want it to do).

Type Description / Example(s)
Client / Workstation personal computer (or PC)
Server responds to requests from a Network
Hand-held phone, audio player
Embedded System toaster, car
Mainframe a large Server
Supercomputer a many-Processor system

Characteristics of Memory:

• turns bits (0's and 1's) into bytes (8-bits) with addresses (i.e.: a specific location in Memory)
• stores code and data of programs that are running
• volitale (i.e.: loss of power = loss of info)
• faster than a Hard Drive

Characteristics of a CPU:

Programming Model - a simplified view of what a CPU does to help programmers understand it better

CPU Instruction - a specific sequence of bits that signals a specific action, some essential task, such as...

Arithmetic - addition and negation

Bit Logic - NOT, AND, OR, XOR ("Exclusive OR")

Jumps - go to a particular address

Copy - duplicate bytes from this address

Register - a small area of Memory

There are two types of Register within the Processor itself:

1. Status Register - stores data that affects the operation of the CPU
2. General Purpose Register - stores all other data

When data is needed from Storage (i.e.: a Hard Drive), it is copied to Memory before being copied to the Registers of the CPU.

Instruction Set Architecture (ISA) - the Instructions that work with a particular CPU and the Registers that it has

Big-Endian - starting with the most significant byte when copying data between Memory and the Registers of the CPU

Little-Endian - starting with the least significant byte when copying data between Memory and the Registers of the CPU

[In other words, does it start writing from the bit with the lowest place value (Little-Endian) or from the bit with the highest place value (Big-Endian)?]

Here is the overall relationship between speed and capacity between all of these different areas:


This is known as the Storage Hierarchy (or Memory Hierarchy).



How The Hardware & Software Communicate

The first piece of software to load when a computer is powered on is the Boot Firmware. It triggers the loading of the Operating System from the Hard Drive.

The Boot Firmware is usually stored in a dedicated chip powered by a battery. This chip is called the BIOS (or Basic Input / Output System). [The chip is similar to the CMOS (or Complementary Metal-Oxide Semiconductor).]

These Instructions are loaded into a particular address that the CPU is hardwired to:


[UEFI (or Unified Extensible Firmware Interface) is a newer "standard" for how these Instructions are loaded that we won't cover here.]

Devices communicate with the CPU by writing to their own Registers in a similar manner:


Or, by sending Instructions to a "Controller" between the CPU and the device. For example:


The CPU can read and write device Registers in two different ways:

Memory-Mapped I/O - addresses are mapped to device Registers instead of to RAM

Port-Mapped I/O - a separate address space (Ports) for device Registers is used

These can be hardwired or dynamically assigned at startup.

Polling is when code in the CPU checks the device Registers to see if they need the CPU to do something.

Instead of Polling, an Interrupt Line is a connection to the CPU that can allow a device to Interrupt (i.e.: signal it to run "Interrupt Handler Code" within the "Interrupt Table"). This makes the CPU save its state, jump to that address to run the code within it, and then returns to the saved state to continue it.


A Hardware Exception is similar to an Interrupt. When encountering it, the CPU jumps to the "Exception Handler Code" within the "Hardware Exception Table". Hardware Exceptions are usually triggered by Illegal Operations (i.e.: Instructions that cannot be handled by the CPU), like division by zero.



What We Need To Know For Programming A CPU

Instruction Set Architecture (ISA)
What are the Instructions that work with a particular CPU and what Registers does it have?

Byte Size
How many bits make up each byte of addressable Memory? It is normally 8-bits.

Word Size
What is the number of bits a CPU can handle efficiently? This usually corresponds to the size of the General Purpose Registers.

Address Size
What is the number of bits used for each address? It is normally 48-bits.

Cache Speeds, Cache Sizes
What is the size and speed of the Cache within the Processor?

Big-Endian or Little-Endian
What is the byte order when copying between Memory and the Registers of the CPU?

Memory-Mapped I/O or Port-Mapped I/O
This is important to know when writing Drivers for devices or Operating Systems.

• Number of Processors / Cores
A Core is the part of the Processor doing most of the work. Multiple Cores allow for multiple things to be done simultaneously.



Part 2: Operating Systems

[Video Link]