osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: stack contents at function call - msg#00000

List: linux.assembly

Date: Next Index Thread: Next Index

Hello Assembly Gurus

I'm working on Assembly programming under linux from few days, here are some
issues

1.When a function call is made the parameters are pushed on to the stack and a
a call
to the function is made.

Now the top of the stack is the return address, Please correct me if I'm wrong
here,
and the parameters above it is the first parameter sent and so on..

1. Is this OS dependent, or compiler dependent?
2. Does this sequence change when call from C language and call from assembly.

Cos I noticed difference with gcc(GNU compiler) and icc (Intell compiler)


Help is needed urgent,

Thanks in advance...



--

With Best Regards
Vadiraj C S

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html



Was this page helpful?
Yes No
Thread at a glance:

Next Message by Date: click to view message preview

Re: stack contents at function call

Hi, Vadiraj C S wrote: Hello Assembly Gurus I'm working on Assembly programming under linux from few days, here are some issues 1.When a function call is made the parameters are pushed on to the stack and a a call to the function is made. right in most systems compilators (x86 works that way, for example) Now the top of the stack is the return address, Please correct me if I'm wrong here, and the parameters above it is the first parameter sent and so on.. 1. Is this OS dependent, or compiler dependent? It depends... ;) Sure, it is NOT OS dependent. On Linux, for exemple, this may work different from hardware to an other. For exemple, on x86, as there is not a lot of registers, all is passed on a single stack. But on other architectures, wich have more registers, functions parameters are splitted in registers (integers and float registers) and in stack when there are no register free. Now, if you want a program to interact with others, you may respect calling conventions. Since it is most likely to occurs (programs call each others), you may guess compilers works the same way on a arch/OS. 2. Does this sequence change when call from C language and call from assembly. In Assembly, you can use what method you want to pass parameters. Look at interrupts, for exemple. They only use registers as parameters. So, you may create functions that only need registers as inputs, and other functions that need stack copying. It's up to your choice. But if you want to interract with other programs, you must respect the arch/OS convention. Convention for C on x86 (I guess you are on this arch) is to pass arguments to stack. So, if you respect this convention from assembly, the sequence is the same. But for C++ compilers, its a bit different (object's methods need a pointer to the instance, 'this'). You must also take care of alignement in stack. C/C++ may align 32bits data. And most likely for 64bits data (long long, double). Cos I noticed difference with gcc(GNU compiler) and icc (Intell compiler) Can you give example? Be more precise... Help is needed urgent, I'm ready to answer quickly today (french time) Fred Thanks in advance... - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html

Next Message by Thread: click to view message preview

Re: stack contents at function call

Hi, Vadiraj C S wrote: Hello Assembly Gurus I'm working on Assembly programming under linux from few days, here are some issues 1.When a function call is made the parameters are pushed on to the stack and a a call to the function is made. right in most systems compilators (x86 works that way, for example) Now the top of the stack is the return address, Please correct me if I'm wrong here, and the parameters above it is the first parameter sent and so on.. 1. Is this OS dependent, or compiler dependent? It depends... ;) Sure, it is NOT OS dependent. On Linux, for exemple, this may work different from hardware to an other. For exemple, on x86, as there is not a lot of registers, all is passed on a single stack. But on other architectures, wich have more registers, functions parameters are splitted in registers (integers and float registers) and in stack when there are no register free. Now, if you want a program to interact with others, you may respect calling conventions. Since it is most likely to occurs (programs call each others), you may guess compilers works the same way on a arch/OS. 2. Does this sequence change when call from C language and call from assembly. In Assembly, you can use what method you want to pass parameters. Look at interrupts, for exemple. They only use registers as parameters. So, you may create functions that only need registers as inputs, and other functions that need stack copying. It's up to your choice. But if you want to interract with other programs, you must respect the arch/OS convention. Convention for C on x86 (I guess you are on this arch) is to pass arguments to stack. So, if you respect this convention from assembly, the sequence is the same. But for C++ compilers, its a bit different (object's methods need a pointer to the instance, 'this'). You must also take care of alignement in stack. C/C++ may align 32bits data. And most likely for 64bits data (long long, double). Cos I noticed difference with gcc(GNU compiler) and icc (Intell compiler) Can you give example? Be more precise... Help is needed urgent, I'm ready to answer quickly today (french time) Fred Thanks in advance... - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by