And understand the concept of memory address

1. The difference with the memory address in hexadecimal 4-digit hexadecimal and 8 bits. For example, can often be seen on some books written in the memory address of 0x0001, written in some other books, it is a memory address 0x00000001. Numbers are represented by the memory address 1, why a four-digit hexadecimal representation, the other is 8-bit hexadecimal representation of it?

First of all, you must know the memory address is just a number, representing a memory space. So how big is this space? The capacity of the original in the memory of the computer as the basic unit in bytes. That is a memory address represents a byte (8bit) of storage space.
For example, often say that 32-bit operating system supports up to 4GB of memory space, that CPU can address only 32 th (4GB) 2, pay attention to here is the 4GB Byte as a unit, not a bit. That is. 4 = There 4G 1024M (Byte). 4 = 1024 1024Kb (Byte) =. 4 1024 1024 1024Byte (8bit), 32-th power of 2, ie 8bit units.

So with four hexadecimal memory address and memory address represented by eight hexadecimal, are in fact represents a 8bit storage space only:
Here Insert Picture Description
Here Insert Picture Description
As for why there is to use four-digit hexadecimal represent memory addresses, and the other with eight hexadecimal representation of the memory address that is based on a different hardware environment. Personal understood: some 16-bit CPU can address (16 address lines), so that a 4-digit hexadecimal address represented suffice. Some 32-bit CPU can address (address line 32), the 8-bit hexadecimal.

Also keep in mind that 210 = 1024

         1G  = 1024 M

         1M  =  1024 KB

         1KB = 1024 B(Byte)

         1Byte = 8 bit

2. Understand memory.

The usual programs and data stored on the hard disk memory, whether you are on or off, and they are there, not lost. Hard drive can store a lot of things, but the speed of its slower data transmission. When it is required to run a program or open data that must be transferred to another small capacity but much faster from the memory on hard disk memory, only after the execution processing is sent to CPU. This intermediate memory is the memory.

Whatever the memory, floppy disk, hard disk or memory, has an address. Because they want to store the data, so it must be assigned an address data according to certain units. With the address, the program can find these data. This is well understood, think about why your family can have a house number.

Learning to program, you must have a thorough understanding of the memory address. Our programming each line of code, each of the data used in the code, needs to have its address on the memory map. Of course, we do not need to know how memory is addressed, it is another class of computer system: operating system thing.

Memory Address:
Computer gave all the information digitally, so it knows himself to a data, a command to remember the memory of which (some) position.
Look at the following example:
If you let your computer remember in memory, "Ding Xiaoming," the name, can be illustrated as:
Here Insert Picture Description
In the first line, each cell represents a section of memory, while the grid is the content data in the record of the contents of this ; in the second row of each cell is within a digital memory corresponding to the address.
Some may wear pecked: Why a "D" word ( "small" "Ming" word, too) occupies two memory address? This is because the Chinese characters stay in less than an address (location), the two must be placed within the contiguous address space. So, what can be placed in a separate memory address in it? Like in English letters, such as 'A', like Arabic numerals: for example, '1', it can, and is placed in a memory address. Suppose a string "ABC", was recorded in memory, it can be illustrated as (we assume this recall from memory at address 2000H):
Here Insert Picture Description
Now a few questions:

Computer remember "D" word memory address is how much? The answer is: 1000H. See the map

We have been saying in the computer, all information is digitized into binary 0, 1, therefore, "Ding Xiaoming" The name is a string should be: 0,001,001,001,110,101 ......, but in view of the drawn, computer memory to remember, is still "Ding Xiaoming," three words ah.

Here is the explanation, we only give one word "small" to explain. We assume that in a bunch of 0,001,001,001,110,101 corresponds to the "D" word, then there is:
Here Insert Picture Description
Let the letter 'A' corresponding figure also drawn:
Here Insert Picture Description
In the above two figures:

The first row are "small" and "A", which is the posters.

The second line is a string of 0 and 1, this is the actual data stored in computer memory.

The third line is a memory address. Not every position occupied by 0 and 1 are compiled on the address. But it has an address every eight.

On the third line, you can understand, a family is assigned a house number, within each household as well as bedroom, living room, which did not address the.

visible:

'D' is indeed by a series of 1s and 0s. More specifically, it can be seen from the figure 'D' is a 16-bit 0 and 1. This number 16 are stored in two memory addressing.

'A' is the same, which is composed of 8 bits 0,1. Accounting for a memory address.

Summary: The memory address is an identifier memory which stores data, not the data itself can be found among the data stored in memory by memory address.

What is the offset?
Assembly language is defined as:

The distance between the actual address segment address of the memory cell section and its location is referred to as segment offset, also called "effective address or offset." Also: the distance between the actual address of its segment address segment of the memory cell is located. In fact, "the distance between the segment address of the actual address where the segment with its" essence

More popular thing about the way the data is stored in the memory: "real address" stored in a data section start address = + offset,

You can also interpret it this way: As the reality of our "home address" = "cell address" + "house number"

The above "offset" like "house number"

In fact, the equivalent of C ++ pointers, like you, point out the exact location. There ......

First, there is a place is the starting point, then how far from the starting point, this distance is offset.
The minimum distance is one byte. .

Guess you like

Origin blog.csdn.net/weixin_41490593/article/details/90664711