Digital Principles and Computer Organization: Unit III: Computer Fundamentals

Memory Locations and Addresses

Computer Fundamentals - Digital Principles and Computer Organization

Computer stores data, instructions in the memory. The data can be in the form of numbers or characters. The memory consists of many millions of storage cells.

Memory Locations and Addresses

• Computer stores data, instructions in the memory. The data can be in the form of numbers or characters. The memory consists of many millions of storage cells.

Each cell is capable of storing 1-bit information having value 0 or 1.

• A single bit represents a very small amount of information. For this reason, the memory is organized so that a group of n-bits can be stored or retrieved in a single, basic operation.

• Each group of n bits is referred to as a word of information, and n is called the word length.

• Fig. 6.4.1 shows the computer memory in the form of collection of words. In most of the memories word length is 8-bit, i.e., byte.

• Looking at the figure, we can say that memory is a array of M number of n-bit words. Each word of memory has an unique address. The address is used to identify a particular word in the memory or memory location. Thus the number and address lines provided by the processor decides the addressing capability of the processor.

• For example, if the processor has 16 address lines it can address up to 216(65536) memory locations.

• Table 6.7.1 shows the relation between memory capacity and the address lines.

Byte Addressability

• As mentioned earlier, the word length of 8-bit is known as byte. However the word length of memory ranges from 16 to 64 bits are simply called word.

• Each byte location of the word has a unique address. That is each successive byte location in the memory is addressed with byte 0, byte 1, byte 2 and so on. Thus if the word length of the processor is 32 bits, successive words are located at addresses 0, 4, 8,..., with each word consisting of four bytes.

Big-Endian and Little-Endian Assignments

• There are two ways that byte addresses can be assigned across words : big-endian and little-endian.

• When lower byte addresses are used for the more significant bytes (the leftmost bytes) of the word, addressing is called big endian.

• When the lower byte addresses are used for the less significant bytes (the rightmost byte) of the word, addressing is called little-endian. This is illustrated in Fig. 6.7.2.


Example 6.7.1 Consider the memory system of a computer storing the following data:

Interpret the storage as numbers in the manner indicated below and find their decimal values in each case.

i) Big-endian storage of 2 hex words of 4-digits each.

ii) Big-endian storage of 2 BCD words of 4 -digits each.

iii) Little-endian storage, in ASCII, of a 4-digit signed hex word.

iv) Little endian storage, in ASCII, of a 4-digit BCD word.

Solution: We know that, big endian storage uses lower byte address for more-significant bytes and little-endian storage uses lower byte address for less-significant bytes. Therefore, in big-endian storage given two words are: 3834H, 3239H and in little-endian storage given two words are: 3932H, 3438H.

i) Big-endian storage of 2 hex words of 4-digit each are: 3834H, 3239H

3834H=3×163+8×162+3×161+4×160= 14388 decimal

3239H=3×163+2×162+3×161+9×160= 12857 decimal

ii) Big-endian storage of 2 BCD words of 4-digit each are: 3834, 3239.

3834 (BCD) = 3834 decimal

3239 (BCD)=3239 decimal

iii) Little-endian storage in ASCII, of 4-digit signed hex word is : 9248H.

Note: We subtract 30H from ASCII code to get the digit value in hex.

9248H = 9×163+2×162+4×161+8×160= 37448 decimal

iv) Little-endian storage, in ASCII, of a 4-digit BCD word is : 9248

9248 BCD=9248 decimal

Example 6.7.2 Represent the number 81234561 in 32-bit Big-endian and little-endian memoryorganization.

Solution:

Word Alignment

• Word length is typically a multiple of 8, common CPU word length being 8, 16, 32 and 64-bits.

• When word lengths are more than 8-bits we have to take special care while accessing words. In the case of a 32-bit word length, natural word boundaries occur at addresses 0, 4, 8, as shown in Fig. 6.7.2.

• In general, words are said to be aligned in memory if they begin at the natural word boundaries. The addresses of such words are called aligned addresses.

• For 16-bit word length aligned addresses are 0, 2, 4, and so on. If the words begin at an arbitrary byte address, the address is called unaligned address. Most of the times we use aligned addresses.


Example 6.7.3 What is word alignment of a machine (microprocessor based system)? Explain. What are the consecutive addresses of aligned words for 16, 32 and 64 bit word lengths of machines? Give two consecutive addresses for each case.

Solution : Consecutive addresses

For 16 bit word lengths: 0, 2, 4, 6, …

For 32-bit word lengths: 0, 4, 8, 12, ...

For 64-bit word lengths: 0, 8, 16, 24, ...

Accessing Numbers, Characters and Character Strings

• We have seen that the number is stored in the memory as a word. Thus it can be accessed by specifying its word address. On the other hand, the character is stored in the memory as a byte and it is accessed by specifying its byte address.

• The character string is stored using successive memory locations in the memory. Since the character strings are of variable lengths we have to specify two things about the strings: 1. Starting address of the string 2. Length of the string.

• There are two ways to indicate the length of the string. A special control character with the meaning 'end of string' can be used as the last character in the string, or a separate number is used to specify the length of the string.

• Thus the string can be accessed by simply specifying the address of the first byte of the character (starting address) or by specifying the starting address and the number indicating the length of the string which can be in the separate word location or in the processor register.


Example 6.7.4 Consider a computer that has a byte addressable memory organized in 32 bit words according to the big Endian scheme. A program reads ASCII characters entered at a keyboard and store them in successive byte location starting at location 1000. Show the contents of the two memory words at location 1000 and 1004 after the name "Johnson" has been entered. (ASCII codes J = 4A H, o = 6F H, h = 68 H, n 6E H, S = 73 H)

Solution: Byte contents in hex, starting at location 1000, will be 4A, 6F, 68, 6E, 73, 6F, 6E. The two words at 1000 and 1004 will be 4A6F686E and 736F6EXX. Byte 1007 (shown as XX) is unchanged.


Review Questions

1. Explain the following:

i) Byte addressability, ii) Big-endian assignment, iii) Little-endian assignment.

2. Discuss two ways in which byte addresses are assigned.

3. What is word alignment of a machine (microprocessor based system)? Explain.

4. What is little endian and big endian memory? Represent the number 64243848H in 32 bits big endian and little endian memory.

5. Explain BIG-ENDIAN and LITTLE-ENDIAN methods of byte addressing with proper example.

6. With relevant figure define the little Endian and Endian assignments.

Digital Principles and Computer Organization: Unit III: Computer Fundamentals : Tag: : Computer Fundamentals - Digital Principles and Computer Organization - Memory Locations and Addresses