Saturday, February 20, 2016

Fundamentals of Computing - Lesson 2 - How the Computer Works

A computer consists of several units each adding up to what you see as a small miracle machine that will serve your every wish. If you wondered why we didn't look at Windows in the first lesson, I will explain that in a future lesson. Right now we are building up the fundamentals you need so you can understand what a computer is all about.


The Core of Your Computer - The CPU
CPU stands for Central Processing Unit. This is what lies at the core of your computer. When measuring speed we talk of megahertz and gigahertz. My first computer ran at 12 megahertz. The one I use today runs at 2 gigahertz, or expressed also as 2,000 megahertz.

Computers work with 0 and 1 at their core level. If you had to explain 4 to a computer it would be rendered as 100 - not one hundred, but four, because of the binary numbering system, which works as follows:

00000001 = 1 (one)
00000010 = 2 (two)
00000011 = 3 (three)
00000100 = 4 (four)
00000101 = 5 (five)

I am sure you get the system. :-)

When you want your computers to do something for you, you need a program. Nowadays, it's so commonplace to just think of clicking a program, so many forget this, but please read as we go along these lessons, so you get the full understanding of what computing is all about.

What Programming Is All About
In the old days, computer programming languages could either be BASIC. DOS 3.3 came with a GW-Basic enterpreter.

When you wrote programs in GW-Basic, you worked with line numbers, such as

10 CLS - clearing the screen
20 PRINT "What is your name? "
30 INPUT NAME$

If you made an error, for instance forgot something, you could insert a line number 21, 22 etc, and then renumber your line numbers, and everything got quite tedious looking back and forth in your source code. The GW-BASIC enterpreter "translated" what you programmed into machine code. We will look at that later in this lesson.

With the arrival of DOS 5.0, the QBASIC enterpreter (Quick Basic) was introduced. It added new functions to basic, and line numbers were removed. It began to look a bit like other programming languages that were available such as Turbo Pascal which was very commonplace in it school environments. You still had to run the QBASIC environment for your programs to work, so you had to make sure that the person you were going to send your program to had the same operating system as GW-BASIC was not compatible with QBASIC, and GW-BASIC didn't come along with MS-DOS 5.0, so when people didn't have the old executable, they couldn't run the program. But let's not lose ourselves in this...

What IS important is knowing that for a computer to execute your instructions it needs machine code. If you tried to open your notepad program in a Notepad window, you would get gibberish such as this:

What you see is impossible to read, but your computer can understand this - which is even shown in somewhat simplified format.

Computers understand a hexadecimal format, where numbers run in the following system:

1 = 1
2 = 2
...
9 = 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

In the old days, you could write assembler code where you pushed and popped according to specific ram addresses for specific variables. When you added a 1 to a certain position in memory, you could provoke the system to reboot, thus starting everything back as you had just turned on your machine. And you could also poke at another area to simulate a cold start, when you wanted to get into your computer's BIOS, which we will be looking at in a future lesson.

In the next lesson we will look at what is around the CPU, so stay tuned for more on the fundamentals of computing.

No comments: