Memory Locations



In order to direct processing operations, the control unit of the CPU must be able to locate each instruction and data item in memory. Therefore, each location in memory is assigned an address. One way to understand this concept is to picture computer memory as a large collection of mailboxes. Each mailbox is a specific location with its own number or address (see Figure below).

 

Each can hold one item of information. Since each location in memory has a unique address, items can be located by use of stored-program instructions that provide their addresses. Sometimes data at a location must be changed, added to, or deleted during execution of the program. The programmer assigns a variable, or symbolic name, to the piece of data that is stored at that memory location.

To understand variables, consider this example. Suppose the computer is directed to subtract TAX from GROSS PAY to determine an employee' s NET PAY. Suppose further that TAX is stored at location 104 and has a value of 55.60 and that GROSS PAY is stored at location 111 and has a value of 263.00. To determine an employee's NET PAY, the programmer instructs the computer to subtract TAX from GROSS PAY. The computer interprets this to mean that it should subtract the contents of location 104 from the contents of location 111.

Programmers must keep track of what is stored at each location, and variable names help in this task. It is easier for the programmer to use names such as TAX and GROSS PAY and let the computer translate them into addresses assigned to memory locations. The term variable means that while the variable name (memory address) does not change, data stored at the location may. The values of TAX and GROSS PAY are likely to change with each employee. The addresses of TAX and GROSS PAY will not.


Last Updated Jan.6/99