室温, 例如,在xv6代码mmu.h中, segdesc就是这样设计的
struct segdesc {
uint lim_15_0 : 16; // Low bits of segment limit
uint base_15_0 : 16; // Low bits of segment base address
uint base_23_16 : 8; // Middle bits of segment base address
uint type : 4; // Segment type (see STS_ constants)
uint s : 1; // 0 = system, 1 = application
uint dpl : 2; // Descriptor Privilege Level
uint p : 1; // Present
uint lim_19_16 : 4; // High bits of segment limit
uint avl : 1; // Unused (available for software use)
uint rsv1 : 1; // Reserved
uint db : 1; // 0 = 16-bit segment, 1 = 32-bit segment
uint g : 1; // Granularity: limit scaled by 4K when set
uint base_31_24 : 8; // High bits of segment base address
};
为什么base定义为base_15_0,base_23_16,base_31_24,但不是'uint base'?
我猜这部分原因是每个子字段都有特殊含义,因此将它们分开存储而不是整体方便访问。 但我不确定猜测是完整还是正确
答案 0 :(得分:1)