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/