flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Atempt (unsuccessful) to make FASM compiler as procedure.

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Hi Privalov.

In recent version of FASMW, compiler itself runs in separate thread.
After finishing compilation, the thread is terminated not via "ret" instruction but with "invoke ExitThread, xxx"
So, I am trying to make it to be simple procedure ending with "ret". But the problem is that on the exit of the procedure illegal stack fault occurs.
Code:
FRESH caused a stack fault in module FRESH.EXE at 0157:004022be.
Registers:
EAX=00000001 CS=0157 EIP=004022be EFLGS=00010202
EBX=00000002 SS=015f ESP=0055fb10 EBP=00000000
ECX=00000014 DS=015f ESI=00404441 FS=3477
EDX=004022bb ES=015f EDI=0000027e GS=0000
Bytes at CS:EIP:
c9 c2 04 00 56 57 e8 52 00 00 00 68 00 00 00 80 
Stack dump:
00418beb 00431d88 00670000 004043b8 00402130 0055fd16 0052f038 00401478 0055fb3c 004152b9 00418beb 0055fb68 0041cd47 0000701a 00000000 0052f038     


Privalov, do you think this is my fault somewhere in the implementation, or it is some general FASM requirement, that it must run in separate thread?

Regards.
Post 10 Sep 2003, 04:24
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
JohnFound wrote:
In recent version of FASMW, compiler itself runs in separate thread.
After finishing compilation, the thread is terminated not via "ret" instruction but with "invoke ExitThread, xxx"

Wouldn't it be possiböle to change the return address to a place where it "returns" to a ExitThread call?

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 10 Sep 2003, 04:38
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
You have to save and restore stack frame in order to get it working with ret.
Post 10 Sep 2003, 08:45
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Privalov wrote:
You have to save and restore stack frame in order to get it working with ret.


I am using standard enter/return macroses. Do you mean something similar?
Post 10 Sep 2003, 08:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
No, you have to store initial ESP in some variable and restore it before using ret instruction, because position of ESP register on calling the exit_program label is indetermined.
Post 10 Sep 2003, 09:39
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Thanks, it works now. Smile
Post 10 Sep 2003, 10:04
View user's profile Send private message Visit poster's website ICQ Number 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.