function - what is the meaning of _AX = 1000 in the following C program? -


i beginner in c programming language, have started learning functions, have studied functions use keyword return return value in caller function. example following program.

int getval(){  return 1000; }  int main(){ int x = getval(); printf("x = %d",x); return 0; } 

will print x = 1000

but confused (under turbo c compiler 32 bit) why following program producing output x = 1000 too. please explain.

int get_val(){  _ax = 1000; }  int main(){ int x = get_val(); printf("x = %d",x); return 0; } 

the "return value" returned in particular register (defined "abi", application binary interface, describes how compilers should generate code), in x86 systems, eax (32 bit) or ax (16 bit) [not saying _ax isn't eax internally].

this compiler supports using "register" directly naming _ax. loading [e]ax register value, returning value.

this won't work in other compiler, although inline assembler can achieve same thing.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -