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 3,402 of 4,675    |
|    Terje Mathisen to luserdroog    |
|    Re: indexing sp in 8086    |
|    12 May 18 13:43:47    |
      From: terje.mathisen@nospicedham.tmsw.no              luserdroog wrote:       > On Friday, May 11, 2018 at 10:09:04 PM UTC-5, Alexei A. Frounze wrote:       >> If you must preserve bp, then you can do something like this:       >> mov ax, bp       >> mov bp, sp       >> mov bp, [bp+2]       >> xchg ax, bp       >>       >> If you don’t:       >> mov bp, sp       >> mov ax, [bp+2]       >>       >> Alex       >       > I've settled on using si for now. bp seems tempting for this, but       > you always have to have a displacement even if it's zero because       > mod=0 r/m=6 does something else. So using si I have       >       > mov si, sp       > mov ax, [si] ; smaller encoding       >       > and       >       > mov si, sp       > mov ax, [si+2]              This fails every time SS is different from DS!              You _must_ use BP (which defaults to SS just like SP) or you need a ES:       override on the addressing.               mov si,sp        mov ax,[es:si+2]              But if you have SI as a spare register you can also use stack operations:               POP SI        POP AX        PUSH AX        PUSH SI              which is just 4 bytes of code.              Terje              --       - |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca