home bbs files messages ]

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,403 of 4,675   
   luserdroog to Terje Mathisen   
   Re: indexing sp in 8086   
   12 May 18 07:15:08   
   
   From: luser.droog@nospicedham.gmail.com   
      
   On Saturday, May 12, 2018 at 6:54:33 AM UTC-5, Terje Mathisen wrote:   
   > 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.   
   >    
      
   Thanks. I totally missed that since my emulator doesn't do segments yet.   
   Looking at Table 2.2 Logical Address Sources confirms your conclusion.   
   BP is the only other register which defaults to SS.   
      
   My primary reference is actually my emulator source because it also   
   shows me which instructions I can actually use. But that can lead me   
   to this kind of oversight.   
      
   --- 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