Memory Locations and Addresses
The instructions in addition to the numbers, arithmetic operations and operands are stored in the computer memory. In this blog, we will consider the organization of memory in the computer system. There are innumerable storage cells in the memory. Every bit in the memory stores the information in the form of 0 and 1. If you are thinking the reason for the millions of storage cells, it is because the bits can store the minute amount of information. That is why a large number of cells. The best and the natural approach of the handling of these cells in the form of groups of fixed size.
To serve this purpose, the memory in the computer system is organized and treated in the form of groups of n-bits. These are stored, and the basic operations are performed. The name given to every group of n-bits is the word of information, and the word length is to represent n, that is the number of bits in the groups. We can represent the words systematically. The top of the memory word contains the first word, and second is in the second block of memory. In the 32 bits of the memory block, the first bit is in the rightmost side and this continuous.
MODERN COMPUTERS BIT SIZES
The computers which we use in the 21t century use the memory size from 16v to 64 bits. This is called the word length.
We can store 2’s complement number in the 32-bit word length of the computed length. And if talking about the characters, four ASCII can be stored in the same memory size. It is because each character stores 8 bits of memory.
1 unit of 8 bits= byte
For memory representation, we need one or more word lengths for instructing the memory.
Accessing the memory for storing and retrieving any single information item needs various names and addresses. It has to be done for every memory location, and it can be either in the form of a word or a byte. The use of the numbers from 0 to (2^k)- 1 is customary for the memory locations in the addresses. The value of k can be anything.
What constitutes the address space? It is 2^k. This shows that the memory locations can reach up to the same number of memory locations, i.e. 2^k.
For example, an address space of 2^24 locations is generated by a 24-bit address. 16M or 16 mega is used for the representation of this number. Here, M = 2^20. For the 32-bits addresses, an address space of 4G or 4 Giga is generated. Here, g= 2^30.
Other notations are-
K (kilo)= 2^10
T (tera) = 2^40.
ADDRESSABILITY OF BYTES
Till now we have come up with three information qualities, these are the bit, byte and word. The value of a byte is always 8 bits, and there is no fixed value of a word. It varies from 16 to 64 bits. Yes, the allocation of various addresses to a single memory location is not practical. Then what is the practical approach? It is the usage of the successive addresses for referring the successive byte memory locations. These are one of the approaches which the modern day computers have been using. The term which is used for the approach is a byte-addressable memory. The addresses with the byte locations are 0,1, 2... and so on. For example, we have a 32-bit word length in the memory, then the memory locations of the bits begin from 0, 4, 8 and go to every bit which is a multiple of four.
WAYS OF ASSIGNING BYTE ADDRESSES
We use two ways for assigning the bye addresses across words. The name of the two ways are-
1. Big-Endian- When we have lower bytes of addresses, we use this approach. It is helpful in getting the words’ more significant bytes.
2. Little-Endian- When there are less significant bytes of the word which are present in at the rightmost bytes, the name which is used for the opposite ordering is Little-Endian.
The relation of the phrases, most significant and less significant are used in the context of weights, i.e. the power of 2. These are the weights which are used in the word representation and are assigned to the bits.
What is similar in both these ways?
It is their application part, i.e. they are used in the commercial machines. In addition to this, the addresses used for the successive memory words are 0, 4, 8 and so on. Also, they are used when we need reading, writing the operations for words in a specific way.
Moreover, there is also a need for the bits’ specific-labelling and that too within the word and the byte. It has to be done in addition to the specification of the ordering bytes of the address in a word. The most natural and the effective ordering is this and helps in the encoding of the data in the numeric form. One more application of the ordering technique is the labelling of the bits from the left to the right position. It happens in the form of a7, a6, a5…., a0.
ALIGNMENT OF THE WORD
As we have already discussed that the addresses in the word in the 32-bit length go as 0,4,8 and so on, the name which is given to such pattern is aligned addresses. There is an alignment of the word in the memory. Remember, that if there are multiple of the byte addresses in a word, then the word alignment begins with those multiple addresses. For example, we have a word length of 16 which is of 2 bytes; the byte address will begin at 0,2,4 and so on. For a comprehensive look, see the example of the word length of 64. It is of 2^3 bytes, and then the beginning of the byte addresses is from 0, 8, 16 and so on.
Are you thinking a reason for not arbitrarily addressing the numbers? Then stop wasting your time and energy. There are no fundamental reasons. The name which can be given to the other form of addresses is unaligned addresses. There are many computers which use the unaligned addresses.
NUMBERS, CHARACTERS AND STRINGS AND THEIR ACCESS
One number= one word.
Accessing the number can be specifically done in the form of word addresses. Same is the case with the individual characters; byte addresses are used for this.
Handling the character strings and that too of variable length is necessary for several applications. At the beginning of the character string, we indicate the given byte address. It contains the byte in its first character. There is the availability of the successive string characters in the successive locations. We can indicate the string length in two ways. Use a special string of characters, “end of the string,” at the last character for marking the end. The other way is to use the number of the characters used in the byte string in a separate memory word location.