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

  • SEARCH
  • Home
  • 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 8551071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:06:44+00:00 2026-06-11T14:06:44+00:00

I know that when calling a non-static member function of an object in c++,

  • 0

I know that when calling a non-static member function of an object in c++, the this pointer is passed in ecx register. What about static functions, as there is no this pointer, does the compiler use ecx register to pass one of the regular parameters in this case?

Edit – I’m talking about the cdecl calling convention here.

  • 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-06-11T14:06:45+00:00Added an answer on June 11, 2026 at 2:06 pm

    What ecx (or any other register) is used for when calling functions depends on the calling convention.

    For instance, consider the C++ code

    struct S {
        static void f( int, int ) { }
        void g( int ) { }
    };
    
    void g() {
        S::f( 3, 4 );
        S s;
        s.g( 3 );
    }
    

    Compiling this with Microsoft Visual Studio 2010 (64bit) via

    cl /c main.cpp
    

    And then dumping the assembly via

    dumpbin /disasm main.obj
    

    Gives this for the g function:

    ?g@@YAXXZ (void __cdecl g(void)):
      0000000000000000: 48 83 EC 38        sub         rsp,38h
      0000000000000004: BA 04 00 00 00     mov         edx,4
      0000000000000009: B9 03 00 00 00     mov         ecx,3
      000000000000000E: E8 00 00 00 00     call        ?f@S@@SAXHH@Z
      0000000000000013: BA 03 00 00 00     mov         edx,3
      0000000000000018: 48 8D 4C 24 20     lea         rcx,[rsp+20h]
      000000000000001D: E8 00 00 00 00     call        ?g@S@@QEAAXH@Z
      0000000000000022: 48 83 C4 38        add         rsp,38h
      0000000000000026: C3                 ret
    

    Notice how the first call to the static S::f method has the first argment (3) passed in ecx and the second argment (4) in edx. So the answer to your question is:

    Yes. For this particular compiler, ecx is used to pass one of the parameters in a static function call.

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

Sidebar

Related Questions

OK I know that I may be thinking about this the wrong way but
I know that polymorphism can add a noticeable overhead. Calling a virtual function is
I know that I should have schema of a table before calling NewRow method
I know that this sort of question has been asked here before, but still
I know that this line of code will make the cell text-wrap: $objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setWrapText(true); 'D1'
I am calling a function test() on an anchor tag like this:- <a class=link
I'm getting exception An object reference is required for the non-static field, method, or
Base* optr=new Derived(); delete optr; I know that if Base class has a non-virtual
I know that Phonegap has an event for back button, but it's only available
I know that if port 443 is open that means the remote host supports

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.