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,758 of 4,675   
   Rod Pemberton to James Harris   
   Re: Locals, parameters, callee-save regi   
   04 Jan 19 17:58:29   
   
   From: invalid@nospicedham.lkntrgzxc.com   
      
   On Fri, 4 Jan 2019 14:45:24 +0000   
   James Harris  wrote:   
      
   > On 03/01/2019 21:12, Rod Pemberton wrote:   
   > > On Thu, 3 Jan 2019 07:31:34 +0000   
   > > James Harris  wrote:   
      
   > >> Speaking of which, to make sure practice matched theory I changed   
   > >> my recently written Nasm procedure entry and exit macros to push   
   > >> callee-saves before EBP - and it works. No surprise, I guess, but   
   > >> it's good to prove it with some real code. FWIW, with six x86-32   
   > >> registers saved (all except EAX and ESP) that places the first real   
   > >> argument at EBP+28.   
   > >   
   > > So, you now have a basis of comparison - albeit limited - which   
   > > could be used to provide a preliminary answer your own question.   
   > >   
   > > Other than a reordering of instructions and stack items, is there   
   > > any advantage or disadvantage between the two methods?   
   > >   
   > > Since that test was so easy, is there any reason why you can't   
   > > attempt another dozen configurations on your own?   
   >   
   > Hi, Rod. I am not sure what else you think should be compared.   
   > Perhaps you think my question was about broader issues than it was.   
   > As stated, though, the question was about the specific issue of where   
   > to place locals and callee-saves.   
      
   Yes, and you have shown here (quoted below from another post in thread),   
   that there is at least five places where "saved registers" could be   
   located on the stack from simple changes to your current code, i.e.,   
   before arguments, after arguments, after return address, after saved   
   ebp, after locals.   
      
   JH>   arguments         (pushed first, by caller)   
   JH>   return address    (pushed by call)   
   JH>   saved registers   (pushed by callee)   
   JH>   saved ebp         (pushed by callee)   
   JH>   locals            (made available by callee)   
      
   Given that you might also experiment with caller-saves too, that makes   
   at least ten combinations.  If you experiment with "RET imm16" etc or   
   ESP only, then a few more ...   
      
   But, even if you stick to the original five, you could end up with many   
   more just by using different combinations of x86 instructions which   
   could be used to solve the issue, e.g., ENTER, LEAVE, MOV, PUSH, POP,   
   RET, RET imm16, PUSHA, POPA, etc.   
      
   > Hi, Rod. I am not sure what else you think should be compared.   
      
   You never know what you may find by trying more than what is necessary.   
      
   > I have an answer: save other callee-save registers before saving EBP,   
   > and locals afterwards, and as I mentioned I have implemented it in my   
   > code. Job done. :-)   
   >   
      
   Ok.   
      
   > Insofar as there were broader issues I received some interesting and   
   > useful answers such as having a fixed block, stable ESP and indexing   
   > off ESP.   
      
   Weren't you attracted to "RET imm16" instruction which pops items off   
   of the stack?   
      
   Weren't you attracted to omitting the frame pointer? I.e., ESP only.   
      
   PUSHA?   
      
   LEAVE?   
      
      
   Rod Pemberton   
   --   
   Isn't the SpaceX car, space junk? Elon Musk, space polluter.   
      
   --- 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