为什么GCC会生产ANDL $-16? [英] Why does GCC produce ANDL $-16?

查看:40
本文介绍了为什么GCC会生产ANDL $-16?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来理解 GCC 这样做的原因

I need some help understanding why GCC is doing

main:
    pushl   %ebp
    movl    %esp, %ebp
    andl    $-16, %esp   # ???
    subl    $48, %esp    # ???
    movl    $8, 16(%esp)        
    movl    $4, 20(%esp)

为什么要先减16,然后再减48?做 subl $64, %esp 不是更容易吗?

Why does it first subtract 16 and then subtract 48 again? Wouldn't it be easier to do subl $64, %esp?

推荐答案

andl    $-16, %esp   # ???

上一行不是从 esp 中减去 16,而是将它对齐到 16 字节边界.
而下面的就是减法,主要是为了在栈上保留一些空间.

The above line is not subtracting 16 from esp but to align it to 16 byte boundary.
While the following one is to subtract, mostly for reserving some space on the stack.

subl    $48, %esp    # ???

这篇关于为什么GCC会生产ANDL $-16?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆