Open benibela opened 4 years ago
Perhaps lea esp, [esp - 12]
is better? https://github.com/benibela/flre/commit/fb1038d2a808cb93c494ccaa82a8e444938ddbde
or for better compatibly to older compilers:
push ebp
mov ebp,esp
and esp,$fffffff0 // Align stack
...
sub esp,12
...
add esp,12
...
mov esp,ebp
pop ebp
or somewhat in this direction.
Which older compilers?
Compilers that do not know lea
? I just tried it in Delphi 4 and it knows it
Or compilers that some other kind of alignment?
FPC 3.3.1 (perhaps 3.2 as well) assumes the stack is 16-byte aligned
Without the alignment, it throws an runtime error "Stack overflow" when compiled with stack checking
-Ct
For example:
This would fix that:
but it is probably too slow, and only changes two of the calls