Can someone give me some real example to help me understand what is the callee and what is the caller in assembly language? I have been through most of the sources, but still I can't get how to distinguish between the callee and the caller. Thank you in advance. (I am adding this explanation - THANK YOU AGAIN! sorry for the code I am new here and do not know how to insert the code to display properly) I am trying to understand this piece of code - learning the basics of assembly. I am trying to add comment for each command (I am sure someone else like me would need it too:
sub_401040 proc near
.text:00401040
.text:00401040
.text:00401040 000 push ebp ; Push the content of ebp register onto the stack
.text:00401041 004 mov ebp, esp ;Allocating 8 bytes of storage ; move the esp register content into ebp register
.text:00401043 004 push ecx
.text:00401044 008 mov eax, [ebp+8]
.text:00401047 008 push eax ; Push eax contents onto the stack
.text:00401048 00C call ds:lstrlenA
.text:0040104E 008 add eax, [ebp+0Ch]
.text:00401051 008 mov edx, eax
.text:00401053 008 mov ecx, 1 ;Set buffer address
.text:00401058 008 call sub_401000
.text:0040105D 008 mov [ebp-4], eax
.text:00401060 008 mov ecx, [ebp-4]
.text:00401063 008 shl ecx, 2
.text:00401066 008 mov [ebp-4], ecx
.text:00401069 008 mov edx, [ebp-4]
.text:0040106C 008 push edx
.text:0040106D 00C push offset aResultD ; "Result: %d\n"
.text:00401072 010 call ds:printf
.text:00401078 010 add esp, 8 ; clean up the stack by adding the size of the argument to esp register
.text:0040107B 008 mov eax, 539h
.text:00401080 008 mov esp, ebp
.text:00401082 004 pop ebp ;Restore old frame pointer
.text:00401083 000 retn ; Return near
.text:00401083 sub_401040 endp
I read that, in order to define the calling convention I need to figure out who is the caller and who is the callee :) I spent so much time to understand the logic: is call ds:lstrlenA means is the callee? and the sub_401040 is the caller? and can we have more than one calling convention in one program? like cdecl along with stdcall? I am not a programmer, and I am not writing a code, I just want to understand how this works to help analysing viruses.