c - From Compiler to assembler -


i have question regarding assembler. thinking of how c function takes multiple parameters argument transformed assembly. question is, there subroutine in assembly takes arguments parameter operate? code might this:

call label1, r16. r16 subroutine input parameter.

if that's not case means each time c function called, gets assembled subroutine parameters related specific call being substituted automatically in it. means whenever c function called, compiler transforms inline function sure not case either :d

so right? alot! :)

the compiler uses "calling convention" can specific 1 compiler 1 target architecture (x86, arm, mips, pdp-11, etc). architectures "plenty" of general purpose registers, calling convention starts passing parameters in registers, , uses stack, architectures not lot of registers stack if not used parameter passing , return.

the calling convention set of rules, such if follows rules can compile functions objects , link them other objects , able call each others functions or call themselves.

so bit of hybrid of assuming. code built function in respects custom function number , type of parameters dictate registers or how stack consumed , how. @ same time functions conform same formula more alike different.

on arm example might have 3 integers being passed in function, arm calling conventions have seen (generally find though vary across compilers doesnt or in case of arm , mips , others try dictate convention rather compiler folks trying it) first parameter in c function come in in r0, second in r1 , third in r2. if first parameter 64 bit integer though r0 , r1 used first parameter , r2 gets second , r3 third, after r3 use stack, ordering of parameters on stack dictated convention. when caller or callee's code compiled using same c prototype both sides know find parameters , construct assembly language that.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -