local variable storage allocation in assembly -


The following snippet is often used to allocate storage for local variables when

 

Code> addl $ 8,% esp // allocated 8-byte storage Push% ebx // Store some value on the stack

Why not only push the value on the stack, but also in advance Allocated to the place?

If you are asking why the compiler makes push commands instead of direct storage, the stack pointer Manipulation, it's a matter of efficiency.

Automatic variables (anyway in C) are not undefined, so the code sequence will be (I'm going to use the stools because I was stacking up in memory):

< Pre> c code actual assembly your suggestion zero x (zero) {int a; Subl 8,% esp push 0 int b; Push 0 :: blah blah blah blah}

My answer is that in this case it is unnecessary and inefficient:

  c code actual assembly your suggestion zero X (zero) {int a [100]; Subl 400,% esp push 0 push push 0 ::: push 0 ::: blah blah blah  

The offer you offer can understand for some:

  C code your suggestion zero x (zero) {int a = 7; Push 7 int b = 9; Push 9 inches [4]; Subl 16,% esp ::: blah blah}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -