flat assembler
Message board for the users of flat assembler.
Index
> Windows > local varialbles - stack vs .data section |
Author |
|
int0x50 07 Aug 2019, 08:56
how do you manage variables within a function? you keep everything in one .data section or you manage through altering esp?
|
|||
07 Aug 2019, 08:56 |
|
DimonSoft 07 Aug 2019, 16:56
int0x50 wrote: how do you manage variables within a function? you keep everything in one .data section or you manage through altering esp? There’re such words as prologue and epilogue, and the idea behind them is so widely used that it even got into a standard set of procedure macros shipped with FASM. EBP is also there for a reason. |
|||
07 Aug 2019, 16:56 |
|
ProMiNick 07 Aug 2019, 17:33
Until thou got stack overload error thou could keep variables anywhere. In case of growing functional of thour program (stack use) thou will have to start to economy stack resources.
In multythreading app thou will need to economy stack on needs not relative to current thread. Because stack is place for threadvars. |
|||
07 Aug 2019, 17:33 |
|
revolution 07 Aug 2019, 17:39
When deciding between global vs local variables I like to think of global variables the same way as files on a disk. If the data makes sense to be stored in a file then it can also make sense to make it global. Otherwise store it locally.
But locally doesn't always have to be on the stack. If you have a large local data set then you can also allocate memory and store it there. And remember to free it before returning to the caller. |
|||
07 Aug 2019, 17:39 |
|
guignol 07 Aug 2019, 17:40
ok
|
|||
07 Aug 2019, 17:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.