Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,997 of 4,675    |
|    Rick C. Hodgin to patric...@nospicedham.gmail.com    |
|    Re: 8086 Segment Overrides    |
|    15 Sep 17 15:15:06    |
      From: rick.c.hodgin@nospicedham.gmail.com              On Friday, September 15, 2017 at 5:46:11 PM UTC-4, patric...@nos       icedham.gmail.com wrote:       > In 8086 Assembly does "mov ax, [es:bx + di]" specify that "di" is relative       > to the es segment or ds segment?       >       > In other words, is bx relative to es and di relative to es (same override),       > or is bx relative to es and di relative to ds (only one       override)?       >       > Thanks in advance,       >       > Patrick              On the 8086 (and later 80386 and beyond), by default there are natural       relationships between certain registers and data segments.              sp, bp -- Always relate to ss: by default.              di, si, bx -- Always relate to ds: by default, or es: if there are        two operations, such as movsb.              ip -- Always relates to cs: and cannot be overridden. There        is a POP CS instruction, and a JMP FAR and CALL FAR        instructions, but these still load CS with the new value.              So whenever you use an override, you're overriding the default segment       so that all of the memory operands in the rest of the instruction relate       to it.              In your example:               mov ax, [es:bx + di]              By default, di and bx fall into the default ds: segment, so with the       override you are specifying, "Do not use ds:, but instead use es:, for       this one instruction."              If you needed to do more than one instruction, you can save some space       by doing this:               push ds ; Save ds for later use        push es ; Load es onto stack        pop ds ; Get stack value into ds        ; Note: This is effectively the instruction "mov ds,es" which        ; does not exist on the 8086.               ; Do your multiple instructions here               pop ds ; Restore the original saved ds above              Segment overrides consume one additional byte of opcode space as       well, and they affect performance somewhat, so you have to gauge       when to use them, when to not, etc. This often involves quite a       bit of experimentation with different formats on different machines       to see which works best.              This syntax:               mov ax, [es:bx + di]              Is more often seen this way in my experience, with the index register       shown first:               mov ax, es:[di + bx]              It also makes it more clear that the entire memory location of [di+bx]       is being affected by the es: override.              Thank you,       Rick C. Hodgin              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca