How is the return value implemented at the assembly level?

int main(void){

printf("Hello World");

return 0;

}

How is 0 passed as return value at assembly level? Is there a dedicated CPU registry for this job?

UPDATE

Here are 2 tables for transferring / returning data in pdf format, but it does not seem to have accurate information on how the API calling convention is determined and which register is used to store the return address:

alt text

alt text

+5
source share
2 answers

It depends on the architecture. Just for a few examples, on x86, EAX is usually used for return values. On x86-64 it is RAX. In SPARC, it is usually displayed in% o0.

+8
source

.

, . , .

+3

All Articles