Search This Blog

Thursday, 26 September 2013

addressing

In order for computers to manipulate data, they must be able to store and retrieve it on demand. This requires a way to specify the location and extent of a data item in memory. These locations are represented by sequential numbers, or addresses.

     Physically, a modern RAm (random access memory) can be visualized as a grid of address lines that crisscross with data lines. Each line carries one bit of the address, and together, they specify a particular location in memory (see memoRy). Thus a machine with 32 address lines can handle up to 32 bits, or 4 gigabytes (billions of bytes) worth of addresses. However the amount of memory that can be addressed can be extended through indirect addressing, where the data stored at an address is itself the address of another location where the actual data can be found. This allows a limited amount of fast memory to be used to point to data stored in auxiliary memory or mass storage thus extending addressing to the space on a hard disk drive.

     Some of the data stored in memory contains the actual program instructions to be executed. As the processor executes program instructions, an instruction pointer accesses the location of the next instruction. An instruction can also specify that if a certain condition is met the processor will jump over intervening locations to fetch the next instruction. This implements such control structures as branching statements and loops.

addressing in Programs
A variable name in a program language actually references an address (or often, a range of successive addresses, since most data items require more than one byte of storage). For example, if a program includes the declaration

Int Old_Total, New_Total;

  when the program is compiled, storage for the variables Old_Total and New_Total is set aside at the next available addresses. A statement such as

New_Total = 0;

  is compiled as an instruction to store the value 0 in the address represented by New_Total. When the program later performs a calculation such as:

New_Total = Old_Total + 1;

  the data is retrieved from the memory location designated by Old_Total and stored in a register in the CPU, where 1 is added to it, and the result is stored in the memory location designated by New_Total.

  Although programmers don’t have to work directly with address locations, programs can also use a special type of variable to hold and manipulate memory addresses for more efficient access to data (see pointeRs and indiRection).

No comments:

Post a Comment