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 7005857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:24:15+00:00 2026-05-27T21:24:15+00:00

I’ve got a function with signature double func(double,…) and I’m sure all the arguments

  • 0

I’ve got a function with signature double func(double,...) and I’m sure all the arguments I’m passing to func are type double. All arguments are stored in some a vector called arguments, I’m just wondering if there is way to write a generic code to pass any number of arguments specified in argumentVector to func?

something like :

for (int i=0;i<agumentVector.size();i++)
    pushstack(argumentVector[i]);
res = call(func);

so far I’ve tried this code but it seems to have problems:

double* param = &argumentVector[0];

for(int i=0;i<argumentVector.size();i++)
{
    _asm  sub         esp,8;
    _asm  fld         param;
    _asm  fstp        qword ptr [esp];
    param++;

}
_asm  call        func;
_asm  add         esp,10h;
_asm  fstp        qword ptr res;

–just a crazy result I’m getting! this code runs without any problems :

double x[2] = {5,6};
double *param = x;
double res;

    _asm  sub         esp,8;
    _asm  fld         x;
    _asm  fstp        qword ptr [esp];
    _asm  sub         esp,8;
    _asm  fld         x+8;
    _asm  fstp        qword ptr [esp];
    param++;
_asm  call        p;
_asm  add         esp,10h;
_asm  fstp        qword ptr res;

cout << res << "\n";

while in this one arguments are not passed properly!

double x[2] = {5,6};
double *param = x;
double res;

    _asm  sub         esp,8;
    _asm  fld         param;
    _asm  fstp        qword ptr [esp];
    _asm  sub         esp,8;
    _asm  fld         param+8;
    _asm  fstp        qword ptr [esp];
    param++;
_asm  call        p;
_asm  add         esp,10h;
_asm  fstp        qword ptr res;

cout << res << "\n";

do you have any idea why? I though both x and param were simple arrays!

–edit2–

here is the complete assembly code so far VC generates

    double x[2] = {5,6};
010E1A05  fld         qword ptr [__real@4014000000000000 (10EB928h)]  
010E1A0B  fstp        qword ptr [ebp-48h]  
010E1A0E  fld         qword ptr [__real@4018000000000000 (10EB878h)]  
010E1A14  fstp        qword ptr [ebp-40h]  
    double *param = x;
010E1A17  lea         eax,[ebp-48h]  
010E1A1A  mov         dword ptr [ebp-54h],eax  
    double res;
    p(param[0],param[1]);
010E1A1D  mov         esi,esp  
010E1A1F  mov         eax,dword ptr [ebp-54h]  
010E1A22  sub         esp,8  
010E1A25  fld         qword ptr [eax+8]  
010E1A28  fstp        qword ptr [esp]  
010E1A2B  mov         ecx,dword ptr [ebp-54h]  
010E1A2E  sub         esp,8  
010E1A31  fld         qword ptr [ecx]  
010E1A33  fstp        qword ptr [esp]  
010E1A36  call        dword ptr [ebp-14h]  
010E1A39  fstp        st(0)  
010E1A3B  add         esp,10h  
010E1A3E  cmp         esi,esp  
010E1A40  call        @ILT+795(__RTC_CheckEsp) (10E1320h)  

    {
        _asm  sub         esp,8;
010E1A45  sub         esp,8  
        _asm  fld         param+8;
010E1A48  fld         dword ptr [ebp-4Ch]  
        _asm  fstp        qword ptr [esp];
010E1A4B  fstp        qword ptr [esp]  

        _asm  sub         esp,8;
010E1A4E  sub         esp,8  
        _asm  fld         param;
010E1A51  fld         dword ptr [ebp-54h]  
        _asm  fstp        qword ptr [esp];
010E1A54  fstp        qword ptr [esp]  

    }
    _asm  call        p;
010E1A57  call        dword ptr [ebp-14h]  
    _asm  add         esp,10h;
010E1A5A  add         esp,10h  
    _asm  fstp        qword ptr res;
010E1A5D  fstp        qword ptr [ebp-64h]  

    cout << res << "\n";
010E1A60  push        offset string "\n" (10EB834h)  
010E1A65  mov         esi,esp  
010E1A67  sub         esp,8  
010E1A6A  fld         qword ptr [ebp-64h]  
010E1A6D  fstp        qword ptr [esp]  
010E1A70  mov         ecx,dword ptr [__imp_std::cout (10EF3A8h)]  
010E1A76  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (10EF3ACh)]  
010E1A7C  cmp         esi,esp  
010E1A7E  call        @ILT+795(__RTC_CheckEsp) (10E1320h)  
010E1A83  push        eax  
010E1A84  call        std::operator<<<std::char_traits<char> > (10E1294h)  
010E1A89  add         esp,8  
    return 0;
  • 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-27T21:24:15+00:00Added an answer on May 27, 2026 at 9:24 pm

    The following works in Visual Studio, but I think you can easily correct the inline assembler syntax so it fits your compiler’s requirements.

    double variadicDoubleFunc(double, ...)
    {
    }
    
    double callVariadicDoubleFunc(double * doubles, unsigned int numDoubles)
    {
        // sizeof(double) must be 8!
        if (numDoubles == 0)
            return 0.0;
        double * lastDouble = doubles + (numDoubles - 1);
        double result = 0.0;
    
        __asm mov eax, numDoubles
        __asm mov edx, lastDouble
        __asm push esi
        __asm mov esi, esp
        __asm and esp, 0xFFFFFFC0
    
        __asm label_loop:
        __asm sub esp, 8
        __asm fld qword ptr [edx]
        __asm fstp qword ptr [esp]
        __asm sub edx, 8
        __asm sub eax, 1
        __asm test eax, eax
        __asm jnz label_loop
    
        __asm call variadicDoubleFunc
        __asm fstp qword ptr result
        __asm mov esp, esi
        __asm pop esi
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I

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.