1. 程式人生 > >DS, ES, SS, DI, SI, BP, SP, IP, FS 暫存器

DS, ES, SS, DI, SI, BP, SP, IP, FS 暫存器

DS is called data segment register. It points to the segment of the data used by the running program. You can point this to anywhere you want as long as it contains the desired data.

DS叫做段暫存器, 指向當前執行著的程式的資料段. 你可以把它指向任何你想要的地方, 只要那個地方有你想要的資料.

ES is called extra segment register. It is usually used with DI and doing pointers things. The couple DS:SI and ES:DI are commonly used to do string operations.

ES叫做額外的段暫存器. 它通常跟DI一起用來做指標使用. DS:SI和ES:DI配對時通常用來執行一些字串操作.

SS is called stack segment register. It points to stack segment.

SS叫做棧段暫存器, 它指向棧段. 

The register SI and DI are called index registers. These registers are usually used to process arrays or strings.

SI和DI兩個暫存器叫做索引暫存器, 這兩個暫存器通常用來處理陣列或字串.

SI is called source index and DI is destination index. As the name follows, SI is always pointed to the source array and DI is always pointed to the destination. This is usually used to move a block of data, such as records (or structures) and arrays. These register is commonly coupled with DS and ES. 
SI叫做源索引暫存器, DI叫做目的索引暫存器. 正如它們的命名, SI通常指向源陣列, DI通常指向目的陣列. 他們通常被用來成塊地移動資料, 比如移動陣列或結構體. SI和DI通常和DS和ES一起使用.

The register BP, SP, and IP are called pointer registers.

BP, SP, 和IP叫做指標暫存器.

BP is base pointer, SP is stack pointer, and IP is instruction pointer. Usually BP is used for preserving space to use local variables.

BP是基指標, SP是棧指標, IP是指令指標. 通常BP用來儲存使用區域性變數的地址.

SP is used to point the current stack. Although SP can be modified easily, you must be cautious. It's because doing the wrong thing with this register could cause your program in ruin.

SP用來指向當前的棧. 儘管SP可以被很容易地修改, 你還是一定要非常小心. 因為如果這個暫存器搞錯了, 你的程式就毀了.

IP denotes the current pointer of the running program. It is always coupled with CS and it is NOT modifiable.

IP用來指示當前執行程式的當前指標. 通常和CS一起使用, IP是不允許修改的.

So, the couple of CS:IP is a pointer pointing to the current instruction of running program. You can NOT access CS nor IP directly.

所以, CS:IP配對用來指示當前執行的指令地址. 你不能直接訪問CS, 也不能直接訪問IP.

FS和GS暫存器是從386開始才有的. FS主要用來指向Thread Information Block(TIB).