# Intro to Computer Systems

## Hardware Primitives

In their simplest form, computers are very simplistic in their operation: all they do is process basic logic instructions. It performs these operations so quickly -- billions of times a second -- that enough operations to complete significant tasks can be done.

### Binary Representation

All information on a computer is stored in a binary format. This means that everything is written in a two-letter alphabet -- 0 and 1. One such piece of binary information is called a "binary digit", or bit.

Individual bits may be used on their own to denote a certain status level (e.g. true/false, on/off), or be combined to form a binary word. The most common of these is an 8-digit binary word called a byte.

This is where all measures of computer storage come from. For example, "256 Megabytes of memory" is talking about enough memory to store approximately 256 million bytes.

These words can then be given definitions for certain operations. A byte has 256 different combinations -- much more flexible than only two! One such example is the ASCII code; this is a coding scheme to represent letters, numbers, symbols, and basic control information (e.g. new line, tab, escape, etc.)

Bits can also be arranged into words for storing numbers, both integer (whole numbers) and floating-point (numbers with decimals). Many of these representations take up more than one byte; after all, we're often interested in numbers reaching higher than 256. Some encoding schemes for floating-point numbers can reach and exceed 64 bits (8 bytes) in size.

### Memory

Memory is used by computers as a fast, non-permanent way of storing information. Typically, programs and data are loaded from another storage medium into memory, where operations are then executed. A memory address provides a way to uniquely identify each area of memory.

Memory is organised in a flat-file manner, with an address denoting a particular space in memory.

### Processor Internals

The most primitive piece of a computer's processing functionality is the logic gate. A logic gate is a piece of circuitry that takes in a number of inputs, and returns some form of logical result. Through a complex combination of logic gates, circuits to provide more useful operations (such as add, multiply, shift and rotate bits, etc.) can be built.

A computer processor contains the circuitry for evaluating a number of these operations, known as instructions. In order to perform a task, the processor needs to know which instruction to execute (the operator), and the data to operate on (the operands).

Computer programs (a series of instructions and data) are usually stored in memory. When running a program, the processor starts at the "top" of the program, executing instructions using a process known as the instruction cycle:

• Fetch: the next instruction to run is fetched from memory.
• Decode: the instruction information is decoded so the processor knows what circuitry to use.
• Execute: the instruction is run
• Store: the results of the operation

#### Logic Units

The circuitry for performing related operations are grouped together into logic units. The most basic of these is the Arithmetic Logic Unit, which provides basic arithmetic capabilities. More advanced processors often have extra logic units suited to specific tasks. For example, it is normal for today's processors to have a separate floating-point logic unit for decimal calculations.

As part of the "decode" step of the instruction cycle, the processor chooses which logic unit (and which part of its circuitry) to activate for the current instruction.

#### Registers

Registers are places in the processor's circuitry where it can store information about the execution currenly taking place. There are different types of registers for specific purposes, including:

• Data registers, for temporarily storing data