flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 28 Sep 2018, 07:42
You can place a dummy label at the end of the locals list and subtract the first from the last to get the size.
BTW: You might want to consider using rep stosd instead of stosb/loop. Also be mindful of the possibility of getting an exception when your local stack size is more than 4kB in size. You can fill the stack from the top down to properly trigger the guard page allocation mechanism. |
|||
![]() |
|
celtic88 28 Sep 2018, 08:01
@revolution,
![]() |
|||
![]() |
|
Tomasz Grysztar 28 Sep 2018, 10:00
revolution wrote: You can place a dummy label at the end of the locals list and subtract the first from the last to get the size. Code: lea edi,[topmost_variable] mov ecx,NUMBER_OF_VARIABLES ; assuming all are DWORDs xor eax,eax std rep stosd cld Also, probably the best way to do it would be to write a customized prologue macro. |
|||
![]() |
|
DimonSoft 28 Sep 2018, 18:07
I’d ask why would you want to do that. Having variable initialized to zero almost always gives you nothing: you’ll almost certainly write some other value to it. At least it is so for most variables, especially local ones. So, having them initialized to zero just to later be reinitialized to a useful value has no practical sense.
In cases you require exactly zeros it’s not that difficult to perform the initialization manually. One more thing: you may add another local variable later which doesn’t require zero initialization. Will you still include it into the initialization process? Why? |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.