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,551 of 4,675    |
|    R.Wieser to All    |
|    Re: EXE program stack setup questions    |
|    07 Oct 18 10:02:18    |
   
   From: address@nospicedham.not.available   
      
   Alexei,   
      
   > This seems to work.   
   > [snip]   
      
   It does. Its what I tried to describe with #1.   
      
   The problem with it is that SP is not set up (its zero) and thus needs to be   
   initialized by the program. Which causes all kinds of trouble when using   
   "uses {registers}" (pushing registers on the stack and auto-popping them   
   before leaving the procedure) and possibly also when using "local {some data   
   declaration}", as that automatically sets up BP and moves SP down.   
      
   > Oopsie. The question mark should be unquoted.   
   > Otherwise 4096 extra bytes will appear in the .EXE.   
      
   Hmmm ... I'm so accustomed to using them without those quotes that I did   
   not even notice it. Could have made for a heck of a difficult-to-spot bug   
   (of sorts). :-)   
      
   By the way, I'm going to see if I can do something with patching the   
   EXE-files header, especially in regard to the SS:SP field (offset   
   0x18..0x1B).   
      
   Regards,   
   Rudy Wieser   
      
   P.s.   
   To give an idea of the build-in handies that Tasm offers take a look at the   
   below:   
      
   - - - - - - - - - - - - - - -   
   SomeFunction proc   
    arg @@wArg1:WORD,@@wArg2:WORD   
    uses bx,si,di   
    local @@bBuffer[16]:BYTE   
   ....   
    ret   
   SomeFunction endp   
   - - - - - - - - - - - - - - -   
      
   "arg" allows pushed arguments to be referred to by their respective labels   
      
   "uses" pushes the mentioned registers (and memory), which get auto-popped   
   when leaving the procedure, just before a(ny) RET)   
      
   "local" allows declared local storage to be referred to by their respective   
   labels.   
      
   the RET is automatically emitted as a RET {stack skip}, calculated from the   
   declared "arg"s at the top   
      
   The problem is that the above three *must* be used before any instructions.   
   And thats includes setting up the segment registers and initializing the   
   stackpointer.   
      
   --- 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