Update Booting/linux-bootstrap-2md.md

This commit is contained in:
hailin cai
2016-02-19 12:00:05 -05:00
parent e0b47cc83d
commit 2950f4c929

View File

@@ -324,4 +324,4 @@ ENDPROC(memset)
就像memcpy函数一样`memset`函数一开始将`di`寄存器入栈,然后将`biosregs`结构的地址从`ax`寄存器拷贝到`di`寄存器。记下来,使用`movzbl`指令将`dl`寄存器的内容拷贝到`ax`寄存器的滴字节,到这里`ax`寄存器就包含了需要拷贝到`di`寄存器所指向的内存的值。
接下来的`imull`指令将`eax`寄存器的值乘上`0x01010101`。这么做的原因是代码每次将尝试4个字节内存的内容。下面让我们来看一个具体的例子假设我们需要将`0x7`这个数值放到内存中,在执行`imull`指令之前,`eax`寄存器的值是`0x7`,在`imull`指令被执行之后,`eax`寄存器的内容变成了`0x07070707`。The next instruction multiplies `eax` with `0x01010101`. It needs to because `memset` will copy 4 bytes at the same time. For example, we need to fill a structure with `0x7` with memset. `eax` will contain `0x00000007` value in this case. So if we multiply `eax` with `0x01010101`, we will get `0x07070707` and now we can copy these 4 bytes into the structure. `memset` uses `rep; stosl` instructions for copying `eax` into `es:di`.
接下来的`imull`指令将`eax`寄存器的值乘上`0x01010101`。这么做的原因是代码每次将尝试拷贝4个字节内存的内容。下面让我们来看一个具体的例子假设我们需要将`0x7`这个数值放到内存中,在执行`imull`指令之前,`eax`寄存器的值是`0x7`,在`imull`指令被执行之后,`eax`寄存器的内容变成了`0x07070707`4个字节的`0x7`)。在`imull`指令之后,代码使用`rep; stosl`指令将`eax`寄存器的内容拷贝到`es:di`指向的内存。