这是什么描述的init呢? [英] What does this Descriptor's init do?
问题描述
%宏描述3
DW%2及地址0FFFFh
DW%1安培;地址0FFFFh
分贝(%1>> 16)及0FFh的
DW((%2 - ;→8)及0F00H)| (%3及0F0FFh)
分贝(%1>> 24)及0FFh的
%endmacro;LABEL_DESC_DATA:0描述,DATALEN-1,92H
上面的东西都是定义。
下面是关于其init的问题:
XOR EAX,EAX
MOV AX,DS
SHL EAX,4
添加EAX,LABEL_DATA
MOV字[LABEL_DESC_DATA + 2],AX;什么该指令会发生什么?
SHR EAX,16
MOV字节[LABEL_DESC_DATA + 4],人
MOV字节[LABEL_DESC_DATA + 7啊
本宏初始化一个全局描述符表条目(即段描述符)。由于x86架构历史这些描述都有些字段分割在几个部分:
结果
(图片来自 OS开发维基)
该宏接受的基础上,限制和访问值,并将它们放入8字节进入相应的场所。
在code片段初始化描述符的基本
字段的运行时值。因为基本
必须是一个线性地址,它计算该地址首先使用 linaddr =段<&4+偏移
公式(适用于实模式)。
%macro Descriptor 3
dw %2 & 0FFFFh
dw %1 & 0FFFFh
db (%1 >> 16) & 0FFh
dw ((%2 >> 8) & 0F00h) | (%3 & 0F0FFh)
db (%1 >> 24) & 0FFh
%endmacro ;
LABEL_DESC_DATA: Descriptor 0, DataLen-1, 92h
the things above are the definition.
here are the questions about its init:
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_DATA
mov word [LABEL_DESC_DATA + 2], ax ;what happens in this instruction?
shr eax, 16
mov byte [LABEL_DESC_DATA + 4], al
mov byte [LABEL_DESC_DATA + 7], ah
This macro initializes a Global Descriptor Table entry (i.e. a segment descriptor). Due to x86 architecture history these descriptors have some fields split in several parts:
(picture from OS Dev wiki)
The macro takes the base, limit and access values and puts them into corresponding places of the 8-byte entry.
The code fragment initializes the Base
fields of the descriptor to their runtime values. Because Base
must be a linear address, it calculates that address first by using the linaddr = segment<<4 + offset
formula (valid for real mode).
For more info, see the OS Dev wiki: Segmentation, GDT.
这篇关于这是什么描述的init呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!