Author Topic: Calling Convention Conceptual Help  (Read 869 times)

Mondragon

  • Regular Member
  • *
  • Posts: 8
Calling Convention Conceptual Help
« on: February 18, 2018, 02:35:53 PM »
Hi all,

So I've been getting deeper into asm lately and I have a question - from a purely assembler programmer's standpoint, do calling conventions even need to exist? In other words, when I disassemble a program written by a compiler, it follows something like cdecl, fastcall, etc... And it may have your standard push ebp, mov ebp, esp, sub esp, 0E4h .....
push ebp
mov ebp, esp
sub esp, 0E4h
....
...
 and then at the end of the routine,

pop     eax
pop     edx
pop     edi
pop     esi
pop     ebx
mov     esp, ebp
pop     ebp
retn
.....


However, I've noticed that when I write plain assembler or read other people's plain-old assembly programs, there is no need for the whole stack clean-up/set-up stuff and in fact, there are labels used to track where "routines" are, etc....

Sorry for my ignorance, but if someone who is experienced with all of this could elaborate and explain that would be very helpful. Thank you.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Calling Convention Conceptual Help
« Reply #1 on: February 18, 2018, 04:00:01 PM »
from a purely assembler programmer's standpoint... In other words, when I disassemble a program written by a compiler...
 :P

However, I've noticed that when I write plain assembler or read other people's plain-old   assembly programs...
 :P

Sorry for my ignorance...

Well, you need to define a Universe for understanding a little better this conventions. As you will see there are conventions between certain parts, and like the computing world is diverse, there are more than one conventions. So, are they necessary? Yes, of course. When? Where? Why? Well, start with one: stdcall, for example, then with the other, etc.

 :P
Felipe.

AW

  • Member
  • *****
  • Posts: 2228
  • Let's Make ASM Great Again!
Re: Calling Convention Conceptual Help
« Reply #2 on: February 18, 2018, 05:37:52 PM »
Quote
from a purely assembler programmer's standpoint, do calling conventions even need to exist?
By default, assemblers paste default  entry point and exit code on the procedures, usually called prologue and epilogue code. Sometimes, programmers don't want it that way. In 64-bit the situation is even more serious.