Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
The book described the Push:

Pushing a double-word value onto the stack therefore involves first decrementing the
stack pointer by 4 and then writing the value at the new top of stack address. Therefore, the instruction
pushl %ebp has equivalent behavior to the following pair of instructions:
subl $4,%esp
movl %ebp,(%esp)

I just want to know why 4 , not 2, 8?

Please give me some advices.

Thank you
Posted
Updated 14-Dec-10 3:03am
v2

It is 4 because the processor that the book was referencing used 'standard' sizes.

A word is two bytes and a double-word is therefore 4 bytes.

Therefore to allow room on the stack the pointer has to be decreased by 4 bytes - the size of a double-word.
 
Share this answer
 
Comments
lxlenovostar 14-Dec-10 9:17am    
thank you, i think i understand it,by not vivid, i want to see some pictures about this. all in all, thank you very much.
Because a long (at least on a 32 bit machine) is 4 bytes long...
:)
 
Share this answer
 
Comments
lxlenovostar 14-Dec-10 9:53am    
thank you
thank you, i think i understand it,by not vivid, i want to see some pictures about this. all in all, thank you very much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900