1

Say I have void f(int a, int b, int c) { g(a, b, c); h(a, b, c); } in x86 assembly like this:

section .text
f:
    pop dword [res_1]
    call g          ; g(a, b, c)
    call h          ; h(a, b, c)
    push dword [res_1]
    ret
section .bss
res_1:
    resd 1

If g follows the cdecl calling convention, am I guaranteed that g will not alter the parameters passed to it in stack?

jcai
  • 3,448
  • 3
  • 21
  • 36
  • cdecl passes by value with a copy of the argument value on the stack frame. It doesn't matter whether or not the caller "preserves" it, the copy is discarded after the call anyway. – Hans Passant Jan 26 '14 at 22:40

1 Answers1

1

cdecl does not require callee to preserve it's arguments, but most functions do.

Edit: (add info / answer to comments)

(not relevant after the question has been edited) What about your code: the callee is not required to preserve fpu registers either.

I prefer to believe Agner Fog with it, but you may try to find info in ABIs of your operating systems

qwm
  • 1,005
  • 8
  • 10