开发者

Why is EFLAGS bit 1 always set?

I wonder why the undefined second bit of the EFLAGS register is set to 1 by default. All other undefined/reserved bits are set to 0. Does this have a开发者_如何学Python special meaning?


It's "reserved", not "undefined". Presumably it reflects some internal state which is simply not exposed to normal applications.

Sometime undocumented behaviour really means "only internally documented".


Presumably this bit is being reserved for a use where the default/compatible setting would be seen as true.

As an example of where the value assigned to a reserved bit can matter, consider the No-eXecute bit in x86 page tables. Because this bit was defined as reserved with a value of zero, it was not possible to call this an eXecute permission bit (while retaining software compatibility). In addition, with how x86 uses its page table tree, the final permission is generated by the and of the permission settings for all the levels of the page table (except for NX); this makes the each permission bit at least as restrictive as the most restrictive section of virtual memory. However, with NX being 1 as the more restrictive permission, NX must be treated differently (using or instead of and).

Providing a consistent conceptual framework is basic good practice, making memory more reliable (fewer bugs are produced, certain types of bugs are made more obvious, and there is less need to check documentation) and learning easier. By providing a reserved as 1 bit, a value that reasonably defaults to true can have a consistent, straightforward name and representation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜