CPP-understanding memory storage with the help of artifacts VS, cpp --

Source: Internet
Author: User

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)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.