1

While exploring godbolt, I noticed that gcc almost never substracts from rsp. For example:

square(int):
        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], edi ; [rbp-4] is not in square(int)'s stack frame
        mov     eax, DWORD PTR [rbp-4]
        imul    eax, eax
        pop     rbp
        ret

Why? Shouldn't there be sub rsp, 4 for allocating an integer on the stack?

fuz
  • 82,933
  • 24
  • 182
  • 332
gavrilikhin.d
  • 596
  • 1
  • 5
  • 14

0 Answers0