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,404 of 4,675   
   luserdroog to Anton Ertl   
   Re: indexing sp in 8086   
   12 May 18 08:19:24   
   
   From: luser.droog@nospicedham.gmail.com   
      
   On Saturday, May 12, 2018 at 7:24:37 AM UTC-5, Anton Ertl wrote:   
   > luserdroog  writes:   
   > >So using si I have   
   > >   
   > >mov si, sp   
   > >mov ax, [si]   ; smaller encoding=20   
   >   
   > From your definition of NEXT in the other posting I see that you   
   > already use SI as Forth IP (you use LODS in your NEXT), so that's not   
   > a good choice.   
   >   
   > One thing you could do is to use SP as return stack pointer, and   
   > something else (BX or BP?) as data stack pointer.  Indexed return   
   > stack accesses are less frequent (mostly for DO...LOOPs).   
   >   
   > One other thing I would do is to keep the TOS in a register across   
   > word boundaries.  This does not increase register pressure in most   
   > cases (probably in none), because the words with the highest register   
   > pressure have the TOS in a register at the place of the highest   
   > register pressure even if they keep it in memory across NEXT.   
   >   
      
   Thanks, I'll consider those options. I think I'll wait on the TOS   
   in register until I get something running at all.   
      
   Current line-up:   
   SI is forth IP   
   SP is forth data stack ptr   
   BP used for indexing stack   
   DI is forth return stack ptr   
   AX,CX,DX,BX free for functions to use   
      
      
   macro next   
           lodsl           ad   
           jmp *(eax)      ff\0350   
      
      
   drop   
           pop eax         58   
           next   
      
   swap   
           pop eax         58   
           pop ebx         5b   
           push eax        50   
           push ebx        53   
           next   
      
   dup   
           mov (esp),eax   8b\364  8b\106\0   
           push eax        50   
           next   
      
   over   
           mov 4(esp),eax  8b\364  8b\106\2   
           push eax        50   
           next   
      
   rot   
           pop eax         58   
           pop ebx         5b   
           pop ecx         59   
           push ebx        53   
           push eax        50   
           push ecx        51   
           next   
      
   -rot   
           pop eax         58   
           pop ebx         5b   
           pop ecx         59   
           push eax        50   
           push ecx        51   
           push ebx        53   
           next   
      
   2drop   
           pop eax         58   
           pop eax         58   
           next   
      
   2dup   
           mov (esp),eax   8b\364  8b\106\0   
           mov 4(esp),ebx          8b\136\2   
           push ebx        53   
           push eax        50   
           next   
      
   2swap   
           pop eax         58   
           pop ebx         5b   
           pop ecx         59   
           pop edx         5a   
           push ebx        53   
           push eax        50   
           push edx        52   
           push ecx        51   
           next   
      
   ?dup   
           movl (esp),eax  8b\364  8b\106\0   
           test eax,eax    85\300   
           jz 1f           74\1   
           push eax        58   
   1   
           next   
      
      
   1+   
           incl (esp)      8b\364  ff\106\0   
           next   
      
   1-   
           decl (esp)      8b\364  ff\116\0   
           next   
      
   +   
           pop eax         58   
           add eax,(esp)   8b\364  01\106\0   
           next   
      
   -   
           pop eax         58   
           sub eax,(esp)   8b\364  29\106\0   
           next   
      
   *   
           pop eax         58   
           pop ebx         5b   
           imull ebx,eax   f7\353   
           push eax        50   
           next   
      
      
      
   #define NEXT 0xAD,0xFF,0350   
      
   static inline int   
   forth(char *mem){   
     char image[] = {   
       0, 4, 'd','r','o','p',         0x58, NEXT,   
       0, 4, 's','w','a','p',         0x58, 0x5b, 0x50, 0x53, NEXT,   
       0, 3, 'd','u','p', 0 ,         0x8b,0364, 0x8b,0106,0, 0x50, NEXT,   
       0, 4. 'o','v','e','r',         0x8b,0364, 0x8b,0106,2, 0x50, NEXT,   
       0, 3, 'r','o','t', 0 ,         0x58, 0x5b, 0x59, 0x53, 0x50, 0x51, NEXT,   
       0, 4, '-','r','o','t',         0x58, 0x5b, 0x59, 0x50, 0x51, 0x53, NEXT,   
       0, 5, '2','d','r','o','p', 0 , 0x58, 0x59, NEXT,   
       0, 4, '2','d','u','p',         0x8b,0364, 0x8b,0106,0, 0x8b,0136,2, 0x53,   
   0x50, NEXT,   
       0, 5, '2','s','w','a','p', 0 , 0x58, 0x5b, 0x59, 0x5a, 0x53, 0x50, 0x52,   
   0x51, NEXT,   
       0, 4, '?','d','u','p',         0x8b,0364, 0x8b,0106,0, 0x85,0300, 0x74,1,   
   0x58, NEXT,   
       0, 2, '1','+',                 0x8b,0364, 0xff,0106,0, NEXT,   
       0, 2, '1','-',                 0x8b,0364, 0xff,0116,0, NEXT,   
       0, 1, '+',0,                   0x58, 0x8b,0364, 0x01,0106,0, NEXT,   
       0, 1, '-',0,                   0x58, 0x8b,0364, 0x29,0106,0, NEXT,   
       0, 1, '*',0,                   0x58, 0x5b, 0xf7,0353, 0x50, NEXT,   
     };   
     return  memcpy(mem, image, sizeof image);   
   }   
      
   --- 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