flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Dynamic stack size

Author
Thread Post new topic Reply to topic
Posetf



Joined: 01 Mar 2004
Posts: 35
Location: London
Posetf 02 Nov 2005, 12:15
Does anyone know how to dynamically extend the system stack?
fasm defaults to 64K, and I know about the stack directive, but I am thinking dynamically. I have managed to catch some page guard exception or other, but have no idea what I could do next. All I can find on google are a couple of hints that it is possible, but no examples.
Post 02 Nov 2005, 12:15
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 02 Nov 2005, 13:00
maybe alocate bigger chunk of memory, copy wntire stack there and set (somehow) SS:ESP to point there?
Post 02 Nov 2005, 13:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier 02 Nov 2005, 14:23
Posetf,

You don't say what environment you are programming to: Windows, DOS, Linux, ...

If Windows, is the problem when you are using a lot of local variables? If so, you can protect against gaurd page exceptions by using the following:
Code:
        mov     eax, ebp
        sub     eax, 4096
        .while eax, a, esp
                mov     dword [eax], 0
                sub     eax, 4096
        .endw

    

immediately after the declaration of your locals and before any code which might use the stack variables.

This will touch, if necessary, every page of the stack that your locals will use. As each 4096 byte page is touched, it sets up the following 4096 byte page as the next guard page, and will prevent exceptions for this reason.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 02 Nov 2005, 14:23
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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.