I am new here and I am also want to know What is a calling convention assembly language?
A calling convention is a set of rules on how to call a function: Which registers are used, how the stack is used, how data is returned, which registers cannot be changed when a function returns,... High level programming languages, when translating your code to machine language, use some "convention" to do this things, so how the registers, stack etc are used in a predictable way.
It is useful to adopt one convention (any) if you want to remember easily how your functions should be called. For example: For 32 bits programs writen in C there is a convenient convention called 'cdecl', where all arguments to a function are pushed to the stack, from right to left, and the return value is returned in a register (EAX no Intel processors -- or EDX:EAX pair if more then 32 bits). This way to acess the data passed to the function all you have to do is read them from the stack. In 64 bits, usually 'cdecl' uses registers to pass the first 4 or 6 arguments (Microsoft or SysV systems, respectively) - there is, also, rules to use floating point...
In assembly you can use your own convention, unless interfacing with a C function (for example). Another example. Lets say I have a C function to test if an
int is odd:
_Bool isOdd( int x ) { return (x & 1) != 0; }
The compiler probably will create something like this (32 bits code):
; Entry: [ESP+4] = x
; Output: EAX = boolean
_isOdd:
mov eax,dword [esp+4]
and eax,1
ret
Since the function is 'called' the ESP points to memory with the return address and the pushed value is in ESP+4. And the return value is in EAX. But notice this is different for 64 bits, on Windows, for example:
; Entry: ECX = x
; Output: EAX
isOdd:
mov eax,ecx
and eax,1
ret
Linux and SysV systems, in x86-64 mode, EDI is used, instead of ECX.
In your code, in asm, you could use a convention where boolean values could be returned in ZF (zero flag) instead on EAX. The ROM-BIOS, in real mode, uses something like this, returning an error condition in CF (carry flag).
As it was said before, in assembly, the convention used should be "convenient" (pun intended) accordingly to your needs. There are no strict rules there, you can make your own at some level.
But if you intend to interface your code with a high level language created code or with syscalls or a library function, you must obey a "standard" calling convention. Microsoft has its own, Linux and Unixes has their own, microcontrollers have their own. They are "standard" for the processor and the environment (and the compiler in use)...
Notice I cited just ONE calling convention here: cdecl. There are others: fastcall, stdcall, pascal, ... GCC for instance hava an attribute called regparm which allow the use of 3 registers to pass arguments, even in 32 bits functions...
Here's a quick, and not complete, article on
https://en.wikipedia.org/wiki/X86_calling_conventions, in Wikipedia, for reference.