Message board for the users of flat assembler.
> High Level Languages > Dynamic stack size
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.
|02 Nov 2005, 12:15||
vid 02 Nov 2005, 13:00
maybe alocate bigger chunk of memory, copy wntire stack there and set (somehow) SS:ESP to point there?
|02 Nov 2005, 13:00||
farrier 02 Nov 2005, 14:23
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:
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.
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!
|02 Nov 2005, 14:23||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.