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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:43:28+00:00 2026-05-23T18:43:28+00:00

This is a strange request but I have a feeling that it could be

  • 0

This is a strange request but I have a feeling that it could be possible. What I would like is to insert some pragmas or directives into areas of my code (written in C) so that GCC’s register allocator will not use them.

I understand that I can do something like this, which might set aside this register for this variable

register int var1 asm ("EBX") = 1984;
register int var2 asm ("r9") = 101;

The problem is that I’m inserting new instructions (for a hardware simulator) directly and GCC and GAS don’t recognise these yet. My new instructions can use the existing general purpose registers and I want to make sure that I have some of them (i.e. r12->r15) reserved.

Right now, I’m working in a mockup environment and I want to do my experiments quickly. In the future I will append GAS and add intrinsics into GCC, but right now I’m looking for a quick fix.

Thanks!

  • 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-23T18:43:29+00:00Added an answer on May 23, 2026 at 6:43 pm

    When writing GCC inline assembler, you can specify a “clobber list” – a list of registers that may be overwritten by your inline assembler code. GCC will then do whatever is needed to save and restore data in those registers (or avoid their use in the first place) over the course of the inline asm segment. You can also bind input or output registers to C variables.

    For example:

    inline unsigned long addone(unsigned long v)
    {
        unsigned long rv;
        asm("mov $1, %%eax;"
            "mov %0, %%ebx;"
            "add %%eax, %%ebx"
            : /* outputs */  "b" (rv)
            : /* inputs */   "g" (v) /* select unused general purpose reg into %0 */
            : /* clobbers */ "eax"
           );
    }
    

    For more information, see the GCC-Inline-Asm-HOWTO.

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

Sidebar

Related Questions

Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
So this may be a strange request but I'll give it a go. I
I have this strange call stack and I am stumped to understand why. It
I have this strange issue with my web app. You see, I'm using jQuery
Could someone explain this (strange) behavior? Why is the length in the first example
I have a number of domains pointed to the same webserver and would like
I have tried contacting tech support with this question, but it has been over
I have a strange problem which I have been trying to fix for some
This is a strange problem that I am having with WCF trying to send
I have come acrooss a very strange problem. I use a POST request for

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.