Section
01 Part 01 – Computer Memory |
“Computers, huh? I've heard it all boils down to just a bunch of ones and zeroes.... I don't know how that enables me to see naked women, but however it works, God bless you guys.” ~From the television show King of Queens, spoken by the character Doug Heffernan |
Introduction
The
first thing you’ll need to know, is how computers store memory, this will be a
good and simple starting point.
Binary
Computers
store memory in “bits”, each bit can be in one of two possible states:
Bits
are usually grouped together in groups of 4, for example 0100, a group of 4 bits is called a
“nybble”. There are 16 possible nybbles
that you can make:
0000 |
0001 |
0010 |
0011 |
0100 |
0101 |
0110 |
0111 |
1000 |
1001 |
1010 |
1011 |
1100 |
1101 |
1110 |
1111 |
Memorising
bits can become very tricky and very confusing, so to make it easier, each of these
nybbles have a digit that represents them:
Binary |
Hexadecimal |
0000 |
0 |
0001 |
1 |
0010 |
2 |
0011 |
3 |
0100 |
4 |
0101 |
5 |
0110 |
6 |
0111 |
7 |
1000 |
8 |
1001 |
9 |
1010 |
A |
1011 |
B |
1100 |
C |
1101 |
D |
1110 |
E |
1111 |
F |
As
you can see, the left column is our 16 nybbles in binary. In the right column, is the same 16 nybbles,
but in “hexadecimal” form.
So,
as an example here, 0011
in binary is the same as 3 in
hexadecimal, we use hexadecimal digits because they are smaller and easier to
remember, you’ll remember the digit 8
more than 1000 any day. All that you need to remember is that they
are pretty much the same thing.
Counting
Normal
numbers that you use in your every day life count upwards like so:
0,
1, 2, 3,
4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, etc… |
I’m
sure you are more than familiar with counting, hell,
even a 3 year old is capable of counting.
This normal counting system is called “decimal”.
Counting
in hexadecimal however, is slightly different:
0,
1, 2, 3,
4, 5, 6,
7, 8, 9,
A, B, C,
D, E, F,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 21, 22, 23, 24, 25, etc… |
As
you can see, hexadecimal numbers count up to 9 just like the decimal numbers,
but they don’t continue to 10 right away, they count through A, B, C, D, E, F
then 10. These extra 6 digits (A to F)
come after 9. The same applies to all
digits, for example, if you have the number 9F, and you add 1 to it, you won’t
get 100, instead, you’ll get A0.
Binary |
Hexadecimal |
Decimal |
0000 |
0 |
0 |
0001 |
1 |
1 |
0010 |
2 |
2 |
0011 |
3 |
3 |
0100 |
4 |
4 |
0101 |
5 |
5 |
0110 |
6 |
6 |
0111 |
7 |
7 |
1000 |
8 |
8 |
1001 |
9 |
9 |
1010 |
A |
10 |
1011 |
B |
11 |
1100 |
C |
12 |
1101 |
D |
13 |
1110 |
E |
14 |
1111 |
F |
15 |
The table
above shows the 16 possible nybbles in binary, hexadecimal, and decimal, just so we’re on the right
level here, the nybble 1100
in binary, is the same as the nybble C in hexadecimal, and 12 in decimal. They all mean the same thing, just a
different way of representing nybbles.
We’ll
be working with hexadecimal more in this tutorial, and I’ll be calling it “hex”
from now on, as it’s much smaller than hexadecimal.
Data Sizes
By
now, you should know what a nybble is (four bits grouped together), but we also
have other sizes:
Sizes
don’t stop there of course, they do continue, doubling each time, however, the
68k handles data only up to the size of a long-word, and no higher, so we don’t
really need to know what’s beyond that.
Here’s a table to help clear things up a bit:
Size |
binary |
hexadecimal |
nybble |
0010 |
2 |
byte |
0010
1100 |
2C |
word |
0010
1100 1111 0101 |
2C
F5 |
long-word |
0010
1100 1111 0101 1001 1101 0111 0110 |
2C
F5 9D 76 |