What do ds:si and es:di mean in assembly?

new_perl picture new_perl · Nov 1, 2011 · Viewed 16.5k times · Source

The movsb (move string, bytes) instruction fetches the byte at address ds:si, stores it at address es:di, and then increments or decrements the si and di registers by one.

I know esi,si and edi,di registers,

but not ds:si and es:di ,

what do they mean?

Answer

Jerry Coffin picture Jerry Coffin · Nov 1, 2011

ds:si and es:di mean the segment:offset referred to by the registers in question. This is primarily important when you're working in real mode (where offsets are a maximum of 64K apiece).

In real mode, the segment are offset are combined as segment * 16 + offset.

In protected mode, a segment register holds a "selector". The base address of the memory referred to by the selector isn't directly related to the value of the selector itself -- rather, the selector just acts as an index to look up data in a table. In the usual case, however, this means very little -- most (current) protected mode environments are set up with CS, DS, ES and SS all set up with base addresses of 0 and maximum offsets of 4 Gigabytes, so addressing via DS vs. ES makes no difference.