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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:42:12+00:00 2026-05-14T18:42:12+00:00

For the below code, if i want to convert the for loop to in-line

  • 0

For the below code, if i want to convert the for loop to in-line assembly, how would it be done?
(Pardon the weird code, i just made it up.)

1) This is for the x86, using visual studio

2) This is a “how to use in line assembly” question, not a “how to optimize this code” question

3) Any other example will be fine. I will think of some better example code in abit.

OK i hope this is a better example:

int doSomething(double a, double b, double c)
{
    double d;
    for(int i=100;i<200;i++)
    {
        d = a*a + b*b + c*c;
        if(d>i)
            return (i-99);
    }
    return -1;
}
  • 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-14T18:42:13+00:00Added an answer on May 14, 2026 at 6:42 pm

    It would probably start out something like this incomplete and somewhat inefficient example. Should demonstrate the syntax, though.

    double doSomething(void) {
        double a=1,b=2,c=3;
        __asm {
            mov ecx,10
    loop:
            fld a // a
            fmul st(0),st(0) // aa
            fld b // b aa
            fmul st(0),st(0) // bb aa
            fsubp // aa-bb
            fstp c // c = a*a-b*b
    
            // and so on
    
            dec ecx
            jnz loop
        }
        return a+b+c;
    }
    

    Using SSE instructions would be another option.

    The VC++ inline assembler is documented here: http://msdn.microsoft.com/en-us/library/4ks26t93.aspx

    The Intel processor reference manuals are here: http://www.intel.com/products/processor/manuals/

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

Sidebar

Related Questions

I'm trying to build a C++ extension for python using swig. I've followed the
I am attempting to pull some information from my tnsnames file using regex. 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.