ソースを参照

Fix desc about movzbl in linux-bootstrap-2.md

pull/666/head
Jekton Luo 5ヶ月前
コミット
f1237841c1
1個のファイルの変更1行の追加1行の削除
  1. 1
    1
      Booting/linux-bootstrap-2.md

+ 1
- 1
Booting/linux-bootstrap-2.md ファイルの表示

@@ -308,7 +308,7 @@ ENDPROC(memset)
308 308
 
309 309
 As you can read above, it uses the same calling conventions as the `memcpy` function, which means that the function gets its parameters from the `ax`, `dx` and `cx` registers.
310 310
 
311
-The implementation of `memset` is similar to that of memcpy. It saves the value of the `di` register on the stack and puts the value of`ax`, which stores the address of the `biosregs` structure, into `di` . Next is the `movzbl` instruction, which copies the value of `dl` to the lower 2 bytes of the `eax` register. The remaining 2 high bytes  of `eax` will be filled with zeros.
311
+The implementation of `memset` is similar to that of memcpy. It saves the value of the `di` register on the stack and puts the value of`ax`, which stores the address of the `biosregs` structure, into `di` . Next is the `movzbl` instruction, which copies the value of `dl` to the lowermost byte of the `eax` register. The remaining 3 high bytes of `eax` will be filled with zeros.
312 312
 
313 313
 The next instruction multiplies `eax` with `0x01010101`. It needs to because `memset` will copy 4 bytes at the same time. For example, if we need to fill a structure whose size is 4 bytes with the value `0x7` with memset, `eax` will contain the `0x00000007`. So if we multiply `eax` with `0x01010101`, we will get `0x07070707` and now we can copy these 4 bytes into the structure. `memset` uses the `rep; stosl` instruction to copy `eax` into `es:di`.
314 314
 

読み込み中…
キャンセル
保存