I disassembled certain binary file(Linux elf).
And I found this code :
movsl %ds:(%esi),%es:(%edi)
There are two registers ‘ds’ and ‘es’.
I know these are named ‘Segment Register’.
But, there isn’t lines like ‘mov addr, %es (or %ds)’.
Where these registers point to ?
The segment registers get initialized by the OS. For most modern OSes they point to the same Segment that is referring to the whole address-space, as most OSes use a Flat Memory model (i.e. no segmentation).
The reason for not using only
ds(the default for almost all memory accesses) here is that the operands formovsare implicit, and made sense in times of DOS.In times of DOS (Real Mode), there was an actual use of them, since registers where limited to 16Bit and so limited to 64K of address-space. The address space(1M) was divided into overlapping 64K segments.