• Uncategorized

About assembly : Why-does-the-compiler-reserve-a-little-stack-space-but-not-the-whole-array-size

Question Detail

The following code

int main() {
int arr[120];
return arr[0];
}

Compiles into this:

sub rsp, 360
mov eax, DWORD PTR [rsp-480]
add rsp, 360
ret

Knowing the ints are 4 bytes and the array is size 120, the array should take 480 bytes, but only 360 bytes are subtracted from ESP… Why is this?

Question Answer

……………………………………………………

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.