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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:33:36+00:00 2026-06-17T18:33:36+00:00

Since I’m very new to GCC, I’m facing a problem in inline assembly code.

  • 0

Since I’m very new to GCC, I’m facing a problem in inline assembly code. The problem is that I’m not able to figure out how to copy the contents of a C variable (which is of type UINT32) into the register eax. I have tried the below code:

__asm__
(
    // If the LSB of src is a 0, use ~src.  Otherwise, use src.
    "mov     $src1, %eax;"
    "and     $1,%eax;"
    "dec     %eax;"
    "xor     $src2,%eax;"

    // Find the number of zeros before the most significant one.
    "mov     $0x3F,%ecx;"
    "bsr     %eax, %eax;"
    "cmove   %ecx, %eax;"
    "xor     $0x1F,%eax;"
);

However mov $src1, %eax; doesn’t work.

Could someone suggest a solution to this?

  • 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-17T18:33:38+00:00Added an answer on June 17, 2026 at 6:33 pm

    I guess what you are looking for is extended assembly e.g.:

        int a=10, b;
        asm ("movl %1, %%eax;   /* eax = a */
              movl %%eax, %0;" /* b = eax */
             :"=r"(b)         /* output */
             :"r"(a)         /* input */
             :"%eax"        /* clobbered register */
             );        
    

    In the example above, we made the value of b equal to that of a using assembly instructions and eax register:

    int a = 10, b;
    b = a;
    

    Please see the inline comments.

    note:

    mov $4, %eax          // AT&T notation
    
    mov eax, 4            // Intel notation
    

    A good read about inline assembly in GCC environment.

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

Sidebar

Related Questions

since today im facing a strange problem. When i start my app in my
Since I'm very new to jQuery I'm having some troubles with this issue. I'm
Since yesterday it worked, but this morning, I can't figure out why, my app
Since regular jQuery animations are not fluent on iOS ( .hide() , slideDown() ),
Since REST is stateless, each request that comes in has no knowledge of the
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain
Since android 2.3 Google has deleted - <uses-permission android:name=android.permission.MODIFY_PHONE_STATE /> http://code.google.com/p/android/issues/detail?id=54 But on Android
Since HttpUtility is not available in WinRT, I was wondering if there's a straightforward
Since I moved a PHP app to a new server (PHP/5.3.8 running as Apache
Since I started writing this question, I think I figured out the answers to

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.