The best way to describe this is if you look at memory First lets have a look at binary and it relation to hex
We normally convert a number to binary to as to operate on this in the form of switches Lets consider an ordinary house hold light switch It is either on or off
We can represent this by saying the switch is logic one for ON or logic 0 for OFF
So the switch has two states these states are ON or OFF
Hence we can deduce that the switch can be represented in base 2 notation as having
2^ 0 states that is 0 giving us OFF or 2^0= 1 giving us 1 ( It therefore has two states On or Off )
Since all electronics is mostly represented by two states we only count up to one that is we count 0 ,1 , 10 ,11 ,101, 110, 111 and so on
In decimal which is human readable format we count as such 1,2,3,4,5,6,7 and so on up to 10 then we count One one , or 11 , one two, or 12 and so on
We term this base 10
Now lets take this another stage further Lets now consider a row of switches 4 in total
Imagine a bank of 4 switches each switch on and off 4 lights each mapped to a single light that is
Switch zero = light Zero State = 0 = OFF
Switch One = light One State = 0 = OFF
Switch Two = light Two State = 0 = OFF
Switch Three = light Three State = 0 = OFF
Now in order to switch “lights Zero on” and “light Two on” leaving the rest off we would have to change the above as follows
Switch zero = light Zero State = 1 = ON
Switch One = light One State = 0 = OFF
Switch Two = light Two State = 1 = ON
Switch Three = light Three State = 0 = OFF
We could therefore also say each switch represents a bit light pattern comprising in the above example 4 bits or In computer jargon we can say this is a nibble
If you understand this then lets introduce another 4 switches attached to lights as above giving us a bank of 8 switches
Switch zero = light Zero State = 0 = OFF
Switch One = light One State = 0 = OFF
Switch Two = light Two State = 0 = OFF
Switch Three = light Three State = 0 = OFF
Switch Four = light Four State = 0 = OFF
Switch Five = light Five State = 0 = OFF
Switch Six = light Six State = 0 = OFF
Switch Seven = light Seven State = 0 = OFF
If you understood this much brilliant lets move on
Now lets switch (Light two On) , ( Light 3 On ) , (Light 5 On) , and Light Seven On and we going to leave the others off
Let’s see what this would look like
Example 1A
Switch zero = light Zero State = 0 = OFF
Switch One = light One State = 1 = ON
Switch Two = light Two State = 0 = OFF
Switch Three = light Three State = 1 = ON
Switch Four = light Four State = 0 = OFF
Switch Five = light Five State = 1 = ON
Switch Six = light Six State = 0 = OFF
Switch Seven = light Seven State = 1 = ON
As you can see our binary implementation of the switches looks like this
1010 1010 And we can also say we now have two nibbles of light information making up an 8 bit word We can also say the above is 8 bits wide
This could be a computer instruction telling the micro chip for example to switch a pattern of lights on or off
But for easier and quicker use in computing we don’t want to express two 8 bit words for example as binary, or in more understandable terms can you imagine what a 64 bit pattern would look like, we’d be writing down zeros and ones for ever
The computer Industry decided to use what we call base 16 so recall base 10 we count 0 to 9 then 10, 11, 12, 13, 14 and so on
Now we arrive at Base 16
We thus count 0 to 9 and then refer to anything above 9 and below 16 as letters
Hence we count like this
0 ,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
A being 10 , F being 15 I’m sure you can work this out to here
After this we count 10,12,13,14,15,16,17,18,19,1A,1B ,1C,1D,1E,1F
Let’s go back to the 8 bit light pattern or as I said two nibbles or an 8 bit word All are correct
From the above Example 1A we can see this
Light 1 or bit 1 is set to 1
Light 3 or bit 3 is set to 1
Light 5 or bit 5 is set to 1
Light 7 or bit 7 is set to 1
Recall the rest were left off
Which gives us the pattern 1010 1010 from MSB (Most significant bit to Least Significant bit reading the binary pattern from right to left )
Now lets convert the above pattern to Base 15
We first break down the 8 bit word into two nibbles taking the lower nibble first
Example 1C
1010
This is our right hand nibble (The Least significant nibble of our 8 bit word)
Moving from leftt to right we have
2^3 = 8, 2^2= 4, 2^1 = 2, 2^1 =1
1 , 0 , 1 , 0
So
How many 2^ 0 = 1 have we ? Answer= 0
How many 2^1 = 2 have we ? Answer = 1
How many 2^2 = 4 have we ? Answer = 0
How many 2^3 = 8 have we ? Answer = 1
Hence we can say we have (1*8 = 8) + (1*2 = 2) = total = 10 hex for 10 is A
Recall 0,1,2,3,4,5,6,7,8,9,A
Now do the same with the right hand nibble
We land up with A again
Hence our 8 bit word represent in binary was 1010 1010 or Hex 0xAAh
We use the X notation to say that’s the number is represented in hex notation
So what’s this all got to do with addressing you ask
Well I said earlier that we have an 8 bit word consisting of two nibbles I also said we say the word is 8 bits wide
Picture if you will to boxes subdivided into 8 sections
Both directly below each other
We might see this
Word 1 = |1|0|1|0|1|0|1|0|
Word 2 = |0|1|0|1|0|1|0|1|
For the micro to fetch word 1 I need some way of telling the micro which word to get
We therefore use addressing Now recall I also said the 8 bit word can also be referred to as 8 bits wide
Moving from left to right imagine each compartment in these boxes has an address
Just like a block of flats
Bit 7 Word 1 has an address of 0x00h
Bit 6 Word 1 has an address of 0x01h
Bit 5 Word 1 has an address of 0x02h
Bit 4 Word 1 has an address of 0x03h
Bit 3 Word 1 has an address of 0x04h
Bit 2 Word 1 has an address of 0x05h
Bit 1 Word 1 has an address of 0x06h
Bit 0 Word 1 has an address of 0x07h
So what happens when get to Word 2 then How does the processor know how to get this word
If we we add one to 0x07h what do we wind up with ?
0x08h which is the start of word Two
So when the Cpu fetched an instruction which is a word it does so by addressing the memory in hex
It knows that how wide the memory is in other words the cpu knows how many bits are stored in one instruction our above very simple examplethis is 8 bits wide
So its says in layman’s terms
Get the instruction at 0x00h
Execute that Instruction
Turn the lights on as per the word
Its fetches that instruction adds one to the instruction counter once it fetches the last bit in word one and then knows where its position is in memory
It might say next
Get the instruction at 0x08h which is the next word or Word 2
Execute that instruction in otherwords turn those lights on instead switching the others off
This obviously depends on the program that tells the processor which words it should fetch
In a pic micro depending on the IC an instruction is typically 14 bits wide for all 8 bit micros
Hope this explains all of this to you and makes this far easier to understand
For more information please see the following
http://nptel.iitm.ac.in/courses/Webcourse-con...Kharagpur/Embedded%20systems/Pdf/Lesson-5.pdfMark
www.harrington.force9.co.uk