Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3759478
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:19:22+00:00 2026-05-19T10:19:22+00:00

Function parameters are placed on the stack, but compilers can optimize this task by

  • 0

Function parameters are placed on the stack, but compilers can optimize this task by the use of optional registers. It would make sense that this optimization will kick in if there are only 1-2 parameters, and not when there are 256 (not that one would want to have the max number of parameters).

How can one find out the parameter limit (number of parameters) for a certain compiler (such as gcc) where one can be sure that this optimization will be used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:19:23+00:00Added an answer on May 19, 2026 at 10:19 am

    Function parameters are placed on the stack, but compilers can optimize this task by the use of optional registers.

    As FrankH says in his comments and as I’m going to say in my answer, the application binary interface for the system in question determines how arguments are passed to functions – this is called the calling convention for that platform.

    To complicate matters, x86 32-bit actually has several. This is historical and comes from the fact that when Win32 bit arrived, everyone went crazy doing different things.

    So, yes, you can “optimise” by writing function calls in such a way, but no, you shouldn’t. You should follow the standards for your platform. Because the honest truth is, the speed of stack access probably isn’t slowing your code down to that great an extent that you need to be binary-incompatible from everyone else on your system.

    Why the need for ABIs/standard calling conventions? Well, in terms of using the processor registers, stack etc, applications must agree on what means what and where it shoudl go. If one function decided all its arguments were in registers and another that some were on the stack, how would they be interoperable? Moreover, you might come across the term scratch registers to mean those registers you don’t have to restore. What happens if you call a function expecting it to leave some registers alone?

    Anyway, as for what you asked for, here’s some ABI documentation:

    • The difference between x86 and x64 on windows.
    • x86_64 ABI used for Unix-like platforms.
    • Wikipedia’s x86 calling conventions.
    • A document on compiler calling conventions.

    The last one is my favourite. To quote it:

    In the days of the old DOS operating system, it was often possible to combine development
    tools from different vendors with few compatibility problems. With 32-bit Windows, the
    situation has gone completely out of hand. Different compilers use different data
    representations, different function calling conventions, and different object file formats.
    While static link libraries have traditionally been considered compiler-specific, the
    widespread use of dynamic link libraries (DLL’s) has made the distribution of function
    libraries in binary form more common.

    So whatever you’re trying to do with optimising via modifying the function calling method, don’t. Find another way to optimise. Profile your code. Study the compiler optimisations you’ve got for your compiler (-OX) if you think it helps and dump the assembly to check, if the speed is really that crucial

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've always handled optional parameters in JavaScript like this: function myFunc(requiredArg, optionalArg){ optionalArg =
In PHP, function parameters can be passed by reference by prepending an ampersand to
Can it be assumed a evaluation order of the function parameters when calling it
How can I find the parameters of an undocumented Dll function? I have searched
How do I convert function input parameters to the right type? I want to
I have around 8-9 parameters to pass in a function which returns an array.
I have a function that accepts a char* as one of its parameters. I
Please advise how to pass parameters into a function called using setInterval . My
I have a calc function in java script that takes three integer parameters, following
I want to write a function that accepts two objects as parameters and compare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.