Delicious Bookmark this on Delicious
 
Banner
Addressing
Article Index
Addressing
Modes
Stacking

 

We know where you live

The two fundamentals of the computer’s universe are data and address. The data is what you store and the address is where you store it.  Most of the time we concentrate on the data – what is stored and how it is stored - and the address is ignored as a simple number that retrieves the data. In the real world of practical computers, however, the situation is very different. The data is almost boring but how you find it requires a complex and exciting range of techniques. So let’s take a closer look at the way addresses are generated and used deep down at the bottom of Baggage’s Bag.

The whole principle of computer operation is that an address automatically selects a memory location and data is either stored there or retrieved equally automatically. In another article (CPU) we look at the way that the processor, or CPU, interacts with memory to run a program. Inside the CPU are special areas of storage called “registers”. The program counter (PC) is a register that holds the address of the next instruction to be obeyed, i.e. to be fetched from memory, decoded and executed. Other registers are used to store and operate on the data – the A register or Accumulator, for example.

Notice that that A register can be thought of as a “data register” and the PC register can be thought of as an “address” register. In hardware terms these differences amount to which bus – address or data – the register is connected to. In more advanced machine designs the distinction between address or data registers becomes blurred and a register may operate as a data register one moment and as an address register the next.

Inside the Pentium

To make this discussion a little more realistic let’s take the case of a real processor – the Intel Pentium and the whole of the 86x family because there hasn’t been much change since they first introduced. The Pentium has a 32-bit register called EAX which is essentially the A register, or Accumulator. This started life as an 8-bit A register, grew to a 16-bit AX register and then doubled in size to become the EAX 32-bit register. However, in addition to the EAX register the Pentium has more than seven others to keep us occupied – what do they all do?

What’s inside the Pentium

In the Pentium’s assembly language a simple instruction to load the EAX register is written:

MOV EAX,address

where address is the 32-bit address that EAX is to be loaded from. Notice that we are using a convenient mnemonic to write down the machine code. This mnemonic is called “assembler” and it is converted to machine code, i.e. raw binary instruction codes, before it is run by the processor. That is, the MOV is replaced by the binary op code that is translated by the processor into move to the EAX register and the 32-bit address follows. This conversion is just a matter of looking such things up in a table of instruction codes but most programmers prefer to use a program – called an assembler – to do the job.



 
     
Banner
Copyright © 2010 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.