How Computers Work

Computer components

computer comprising processor, memory and I/O devices

Computer operations follow the fetch/execute cycle:

  1. fetch instruction from memory
  2. decode instruction
  3. execute instruction
  4. REPEAT!

How information is represented: it's all "bits"

How do computers represent numbers, text, pictures, sound, movies, instructions?

Computers are electronic devices that understand only two states
(analogous to Morse code)

Computers represent information using a binary arithmetic system in which numbers are represented using the binary digits ("bits") 0 and 1:

DecimalBinary
00
11
210
311
4100
5101
6110
7111
81000
91001
101010
111011
121100
131101
141110
151111

Both systems are positional - the position of each digit in the number determines its value:

The decimal system is also called "base 10" and the binary system "base 2"

Other binary systems:

2 Jacks1 Gill
2 Gills1 Chopin
2 Chopins1 Pint
2 Pints1 Quart
2 Quarts1 Pottle
2 Pottles1 Gallon
2 Gallons1 Peck
2 Pecks1 DemiBushel
2 DemiBushels1 Bushel
2 Bushels1 Kilderkin
2 Kilderkins1 Barrel
2 Barrels1 Hogshead
2 Hogsheads1 Pipe
2 Pipes1 Tun

Number converter:

Experiment with this form to convert between bytes (8-bit binary numbers) and decimal numbers - what's the largest decimal number you can represent?

Binary:

128 64 32 16 8 4 2 1

Decimal:

What's so grand about a positional system? Arithmetic calculations are easier than in non-positional systems, like Roman numerals - imagine what second grade would be like if you had to calculate XLVIII + LXVII = CXV !!

Text representation

Text is represented with the ASCII code, captured in this table:

The ASCII character set

Add the row and column numbers to get the ASCII code - A is represented by decimal number 65 or binary number 01000001, and "Hi!" is represented by the sequence 72 105 33, or binary 010010000110100100100001

Control characters and line endings

The table starts with ASCII code 32 (space character) - the first 32 characters are control characters, used to control the early printers

Representing line endings is tricky: the Mac represents the end of a line with a carriage return character (CR, ASCII code 13), Linux uses a line feed character (NL, ASCII code 10), and Windows uses both

Usually, when you transfer a text file from system to system, the FTP program (e.g. Fetch or WinSCP) substitutes the appropriate line ending - the "text mode" of transfer says to make these substitutions, "binary mode" makes no substitutions and is more suitable for non-text files, such as images or programs

Unicode:

The early ASCII system had space for 256 symbols, only enough to represent all English characters, punctuation marks, numbers, etc.

The global community has shifted to a much larger code called Unicode

Representing other information

Once you can represent numbers and characters, you can also represent instructions! This observation led von Neumann and his collaborators to create the first general purpose, re-programmable computer

In future lectures, we'll learn how the computer represents images, sound and movies

Bits and bytes

A group of bits used to represent a character came to be known as a byte, which is 8 bits

Names for larger groups of bytes:

Modern computers come with huge amounts of storage space on the hard drive (often hundreds of GB), but are usually able to process only a few GB at a time (their main memory or RAM)