Consider this simple program, which calls a proc repeatedly:
include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler
.code
buffersize=40000
algo proc arg
Local var1, buffer[buffersize]:BYTE, var2
mov var1, 123
mov var2, 456
print str$(esi), 13
ret
algo endp
start: mov ebx, esp
xor esi, esi
print hex$(ebx), " at start", 13, 10
.Repeat
sub esp, 100
invoke algo, 12345
inc esi
.Until esi>2000
mov esp, ebx
print chr$(10, "ok?", 13, 10)
print hex$(ebx), " at end"
exit
end start
In my tests, the buffersize limits are as follows - beyond these values, you need to implement stack probing:
Win7-64 40,400
Win10 20,200
WinXP-32 12,100
In practice, the limit for XP can be below 8,000 bytes, as found out in this thread. (http://masm32.com/board/index.php?topic=7511.msg82102#msg82102)
Hi JJ!
Somethings is failing here:include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler
.code
unrolles = 20
repeat unrolles
ifndef topea
topea = 0
buffersize = 8000
else
topea = topea+1
buffersize = buffersize+500
endif
@CatStr(algo, %topea) proc arg
% Local var1, buffer[buffersize]:BYTE, var2
mov var1, 123
mov var2, 456
% mov buffer [buffersize-1], 1
mov esi, buffersize
print str$(esi),@CatStr(<!" >,algo, %topea,<!">), 13,10
ret
@CatStr(algo, %topea) endp
endm
start:
mov ebx, esp
xor esi, esi
print hex$(ebx), " at start", 13, 10
repeat unrolles
ifndef topeb
topeb = 0
else
topeb = topeb+1
endif
sub esp, 100
invoke @CatStr(algo, %topeb), 12345
inc esi
endm
mov esp, ebx
print chr$(10, "ok?", 13, 10)
print hex$(ebx), " at end",13,10
inkey
exit
end start
I expect a crash beyond 12000 (like in your program), but nothing happen. :redface:
0012FF8C at start
8000 algo0
8500 algo1
9000 algo2
9500 algo3
10000 algo4
10500 algo5
11000 algo6
11500 algo7
12000 algo8
12500 algo9
13000 algo10
13500 algo11
14000 algo12
14500 algo13
15000 algo14
15500 algo15
16000 algo16
16500 algo17
17000 algo18
17500 algo19
ok?
0012FF8C at end
Press any key to continue ...
Nothing happens because, unlike in my example, you are probing the stack. Try buffersize = buffersize+5000
If you link with the following switch, you can continue to produce code like the one that caused the mysterious Windows bug.
/STACK:1048576,1048576
The only switch that I really need is the one that blocks certain trolls from my threads :P
No problem with 5000, but with 8000 (when 48000)
But I can "easily" obtain a crash reverting the calling order: repeat unrolles
ifndef topeb
;topeb = 0
topeb = unrolles-1
else
;topeb = topeb+1
topeb = topeb-1
endif
sub esp, 100
invoke @CatStr(algo, %topeb), 12345
inc esi
endm
Very interesting :t
Thanks
Setting stack statically (to 95000) :0012FF8C at start
103000 algo19
98000 algo18
93000 algo17
88000 algo16
83000 algo15
78000 algo14
73000 algo13
68000 algo12
63000 algo11
58000 algo10
53000 algo9
48000 algo8
43000 algo7
38000 algo6
33000 algo5
28000 algo4
23000 algo3
18000 algo2
13000 algo1
8000 algo0
ok?
0012FF8C at end
Press any key to continue ...
Apparently also there is dinamically at least 2 pages of 4k
Quote from: jj2007 on November 14, 2018, 04:42:26 AM
The only switch that I really need is the one that blocks certain trolls from my threads :P
Your threads? Nothing here is yours, although you use the forum resources to spam your buggy crapware without any shame.
Quote from: AW on November 14, 2018, 08:10:44 AMyou use the forum resources to spam your buggy crapware without any shame.
Writes the guy whose posts are always signed with
Visit nottp://www.atelierweb.com :bgrin:
It's very encouraging. Programming Masm... you never grow up :biggrin:
Quote from: jj2007 on November 14, 2018, 01:38:01 PM
Writes the guy whose posts are always signed with Visit nottp://www.atelierweb.com :bgrin:
Distracting attempt, I am talking about the guy that diverts every newbie to an obscure page on the webalice.it site on the pretext of explaining what Masm32 is all about when the sole purpose is to start the indoctrination about his crapware. It really sucks, these dirty tricks.
Quote from: AW on November 14, 2018, 03:12:22 PMan obscure page on the webalice.it site on the pretext of explaining what Masm32 is all about when the sole purpose is to start the indoctrination about his crapware.
The "obscure page" (http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm) is a very condensed two-pager with essential step-by-step instructions on how to install the Masm32 SDK, plus three lines on MasmBasic and one on JWasm (which is outdated, I will change that soon). The bulk of that page is
- a Hello World in pure Masm32
- another one showing the use of local variables
- a list of help files and tutorials
- hints on how to avoid frequent n00b errors, such as register preservation, misunderstandings about signed registers
- hints on frequent problems, like inkey combined with gui builds
and so on.
So that is about 1% MasmBasic, the rest is help for beginners that is difficult to find by scrolling through thousands of forum pages.
What makes you so absolutely furious about this little page, dear forum member AW? That nobody ever looks at
Atelier
Web? If there was anything relevant for an assembly n00b on your site, I would even include your signature ("Visit http://www.atelierweb.com") in my two-pager, but I find the Iczelion tutorials or Randy's Art of Assembly much more interesting for n00bs.
I am a hobby coder. I know I am privileged not having to earn a living with coding. Sorry that your business is not doing well, sorry that you feel obliged to kill your precious time hanging around here, but can you
please stop dumping your accumulated hatred in this forum? Have I ever called your professional hacking software "buggy crapware"? What makes you believe that you have the right to insult other forum members, not only me, when your bowels are acting up?
Another pathetic and idiotic attempt to divert attention. You won this time I will explain a little.
My business is doing very well, I live from it for nearly 20 years and even have to pay other people to help me. At this stage of my life I can afford to spend more time doing things that give me some pleasure like ASM. That is the reason you see me here.
I don't live from Social Security as you appear to, since you are around the forum for many years without any income source or day job.
Note that I simply placed a link to my website as a signature, this is normal, and I never promoted any of my products here. My market is not this. Period.
Your link to webalice link is a complete source of misinformation and bad advices. Most newbies that come here know much more about programming in general than you ever dreamed about. After looking at your webalice they never come here again.
Quote from: AW on November 14, 2018, 07:34:41 PMI don't live from Social Security as you appear to
You are sick, José. Get a shrink and stop insulting people.
:biggrin:
I have always laughed at how well you guys get on together. :P