CPP-understanding memory storage with the help of artifacts VS, cpp --
I also want to know this before. The first is not to learn the underlying layer, but to understand the concept of online search. The second is the end of the story. The example is also complicated, it may be difficult for the non-C direction, so I have never understood it.
Today, I accidentally found out that I had to go through the memory window. I opened my mind and formed my own understanding,If you have any mistakes, you may be grateful.
Open the memory window before debugging:
Monitor the address of I, find this value in the memory window, and find that there is a 32 (50 is converted into a hexadecimal value of 32)
Verify that the token is in hexadecimal format.
My understanding is:
This time, I changed the int value to a hexadecimal value and then checked the debugging result: the CPU usage is basically the same as that of the x86 and ARM architectures.Small-end alignment(High and low)
Obviously, the larger the memory address (0x0018FBF4> 0x0018FBB8), the lower the address we monitor, the lower the address.
0x12345678, the high position is 1, and the low position is 8. I will draw a conversion chart
Then explain why the four
Int, 4 bytes (byte), and 1 byte = 8 bits
See the figure below:
Then, based on the principle of low and low height, it's just like this.
Verify my ideas: (1 is not enough, so use 0)
In the memory, there is a binary number. Now we are performing reverse push, and we naturally have this figure:
Let's talk about things Nima has never been very clear at school. It was actually solved under the VS artifact !!
Extension:
In fact, the number of memory address bits is also exquisite. Switch VS to X64 and find that the memory address is too long.
X86 is 8-bit, that is, 1 byte. Similarly, X64 can be pushed with 2 byte (different environments may have different values)