To both Wilbert and Michael V, apparently you both missed my previous post, as both of your options nullify the benefits and the point of recursion.
Trond wrote:Honestly, initializing them manually is a bigger performance hit than initializing them automatically.
Trond, this may be true if you do a lot of For x=0 to 9 loops. However, in one of my 7500+ lines files, I just counted and I have fewer than 70 "= 0" assignments, and I NEVER trust the compiler to initialize them to zero, so this includes all of my For x=0 loops, as well as every define-time initialization.
In fact, this post made me realize that the
problem is worse than I thought! This code:
Protected a = 0, b = 0, c = 1
compiles to this:
Code: Select all
XOR eax,eax
PUSH eax
PUSH eax
PUSH eax
; Protected a = 0, b = 0, c = 1
MOV dword [esp],0
MOV dword [esp+4],0
MOV dword [esp+8],1
So even though the compiler "initializes" to zero (using the push, as I was aware), it behaves as if the compiler itself is unaware of the initialization! In essence, good programming practice of initializing your own variables produces WORSE output!
This is the preferred output:
Code: Select all
add esp, #8 ; or whatever the syntax is...
MOV dword [esp],0
MOV dword [esp+4],0
MOV dword [esp+8],1
Because then, when I do NOT initialize them at definition (the norm, since they are usually set at first use), a whole slew of variables (8 in this case) can be allocated like this:
add esp, #24
I do appreciate that at least the compiler uses a loop to initialize large amounts (for smaller output)...however, that consumes even MORE time per variable.
; ------------------------------------------------------
I understand some people will not appreciate the improvement realized within the request. Nevertheless, it can make a difference in both output size (minor) and speed of execution (major) when numerous procedures are called recursively (or repetitively). Plus, it will avoid the "penalty" for coding with the good programming practice of initializing your own variables. And in reality, I
must continue to initialize the vars manually myself... afterall, I need the code to read as if the compiler does not, in case I ever port it to another compiler that does not.
I would appreciate if this
option is implemented. I understand, Fred, that you have many requests, and I do appreciate you taking the time to consider this.