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,400 of 4,675   
   luserdroog to Alexei A. Frounze   
   Re: indexing sp in 8086   
   11 May 18 20:29:46   
   
   From: luser.droog@nospicedham.gmail.com   
      
   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]   
      
   For giggles, here's my draft so far. In a form which should   
   be convenient to plug into my emulator.   
      
      
   $ cat forth.h   
   #define NEXT HEX3(ad,ff,e8)   
   #define CHAR(x) *#x   
   #define CHAR2(x,y) CHAR(x),CHAR(y)   
   #define CHAR3(x,y,z) CHAR2(x,y),CHAR(z)   
   #define CHAR4(w,x,y,z) CHAR2(w,x),CHAR2(y,z)   
   #define CHAR5(w,x,y,z,a) CHAR4(w,x,y,z),CHAR(a)   
   #define HEX(y) 0x##y   
   #define HEX2(x,y) HEX(x),HEX(y)   
   #define HEX3(x,y,z) HEX2(x,y),HEX(z)   
   #define HEX4(w,x,y,z) HEX2(w,x),HEX2(y,z)   
   #define HEX5(w,x,y,z,a) HEX4(w,x,y,z),HEX(a)   
      
   static inline int   
   forth(char *mem){   
     char image[] = {   
       0, 4, CHAR4(d,r,o,p), HEX(58), NEXT,   
       0, 4, CHAR4(s,w,a,p), HEX4(58,5b,50,53), NEXT,   
       0, 3, CHAR3(d,u,p),0, HEX5(8b,ec,8b,5,50), NEXT,   
       0, 4. CHAR4(o,v,e,r), HEX6(8b,ec,8b,45,2,50), NEXT,   
       0, 3, CHAR3(r,o,t),0, HEX6(58,5b,59,53,50,51), NEXT,   
       0, 4, CHAR4(-,r,o,t), HEX6(58,5b,59,50,51,53), NEXT,   
       0, 5, CHAR5(2,d,r,o,p),0, HEX2(58,59), NEXT,   
       0, 4, CHAR4(2,d,u,p), HEX4(8b,ec,8b,5),HEX5(8b,5d,2,53,50), NEXT,   
       0, 5, CHAR5(2,s,w,a,p),0, HEX4(58,5b,59,5a),HEX4(53,50,52,51), NEXT,   
       0, 4, CHAR4(?,d,u,p), HEX4(8b,ec,8b,5),HEX2(85,c0),HEX3(74,1,58), NEXT,   
       0, 2, CHAR2(1,+), HEX4(8b,ec,ff,5), NEXT,   
       0, 2, CHAR2(1,-), HEX4(8b,ec,ff,d), NEXT,   
       0, 1, CHAR(+),0, HEX5(58,8b,ec,1,5), NEXT,   
       0, 1, CHAR(-),0, HEX5(58,8b,ec,29,5), NEXT,   
       0, 1, CHAR(*),0, HEX5(58,5b,f7,eb,50), NEXT,   
     };   
     memcpy(mem, image, sizeof image);   
   }   
      
      
   Need to stitch up the link fields somehow.   
      
   --- 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