For 8086 it is possible to override the segment of the source index SI in order to use ES instead of DS. In a book (the old Scanlon) I found this MASM code:
LEA SI,ES:HERE
LEA DI,ES:THERE
MOVSB
As LEA retrieves just the OFFSET of a memory address (16 bits for the 8086), how MOVSB knows that SI refers to the ES segment and not the DS segment? Is LEA changing the default segment for SI? I have not read anything about that in the many pages and manuals I found.
That code looks wrong. Without a segment override prefix, movsb
will use DS:SI
and ES:DI
always. Unless you have to worry about errata of ancient processors you can make this code work by giving a segment override prefix to movsb
. es:MOVSB
will tell it to use ES:SI
rather than DS:SI
. movsb
always copies to ES:DI
; no segment override prefix will change it.
The code could actually be right if DS is guaranteed to equal ES at this location. The old assemblers had their own ides of things and sometimes funny segment overrides had to be used to keep the assembler happy.