Implementation of an operating system: some explanations about align

Source: Internet
Author: User

In the third chapter of the book "Implementation of an operating system", the two code segments use align 32 when the code is written and used. If the code is written, there is no such thing as my poor compilation skills, I have never seen this command ......

In fact, align is a macro responsible for memory alignment. It will add some data so that the following data alignment.

Align 32
// Will be expanded into a similar
Times (32)-($-$) % (32) % (32) NOP



It is for Data Alignment. After you use the data type that affects align, you need to fill it with align so that the subsequent data can be aligned to the boundary.

As for the role here, the beginning of the segment should be 32-byte aligned. But it is not required. In real mode, each segment is 64 KB. The segment register stores 16-bit high addresses, and the IP register stores 16-bit low addresses. In this case, each time the segment register is added with 1, the IP address is 16 bytes different. Therefore, alignment to the 16-byte boundary can make the segment performance more stable. Alignment to 32-bit should be optimized to adapt to the 256-bit high-speed cache.

 

 

Bytes ------------------------------------------------------------------------------------------------------

 

Repost my blog article solemnly states: the famous author of a technical website can be reprinted, and a commercial website can be reprinted only with my consent; otherwise, the website will be held accountable --

Pang123hui blog:

 

Csdnhttp: // blog.csdn.net/pang123hui/



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.