flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > little bug

Author
Thread Post new topic Reply to topic
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 16 May 2005, 13:23
hello, i thinks i found little bug in stdcall.inc, there are no this bug in previous version of fasm

when i compile this proc in fasm:
Code:
  proc  _test, lpParam


        pop     ebp
        ret     4
  endp
    


i get this code in debugger (unwanted opcodes at the end):
Code:
push    ebp
mov     ebp, esp
pop     ebp
retn    4
-
leave
retn    4
-
    

_________________
[not enough memory]
Post 16 May 2005, 13:23
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 16 May 2005, 13:38
This is intended behavior - the new macro detect whether you forgot to put "return" macro there and makes it for you in such case. If you want to do the manual return, don't use "proc" macro!
Post 16 May 2005, 13:38
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 16 May 2005, 13:55
ok, i found other way, i modified stdcall.inc and cdecl.inc

i have removed two lines from endp macro (in both files):
Code:
...
   else
    return
...
    


seems to work ok with any style of return, including manual

ps. thanks for very quick answer
Post 16 May 2005, 13:55
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 16 May 2005, 14:26
This is a bad solution: the "proc" macro is designed to set up all for you automatically, it sets up the stack frame for you, and you should use "return" macro to make it restore the stack and return from procedure correctly. If you do any manual tricks, don't use "proc", but write the procedure yourself from scratch - first, you will better see what's happening, second, your code won't stop working even if the "proc" way of setting up the stack is changed.
Post 16 May 2005, 14:26
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 16 May 2005, 14:55
ok, thanks for explanation, topic can be closed
Post 16 May 2005, 14:55
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.