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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:11:03+00:00 2026-06-15T13:11:03+00:00

I have a for loop in my (c++ .Net Win32 Console) code which has

  • 0

I have a for loop in my (c++ .Net Win32 Console) code which has to run as fast as possible. So I need to make the compiler use a register instead of storing it in RAM.

MSDN says:

The register keyword specifies that the variable is to be stored in a
machine register, if possible.

This is what I tried:

for(register int i = 0; i < Size; i++)

When I look at Disassembly code which the compiler generates, I see:

012D4484  mov         esi,dword ptr [std::_Facetptr<std::codecvt<char,char,int> >::_Psave+24h (12DC5E4h)]  
012D448A  xor         ecx,ecx  
012D448C  push        edi  
012D448D  mov         edi,dword ptr [std::_Facetptr<std::codecvt<char,char,int> >::_Psave+10h (12DC5D0h)]  
012D4493  mov         dword ptr [Size],ebx  
012D4496  test        ebx,ebx  
012D4498  jle         FindBestAdd+48h (12D44B8h)  //FindBestAdd is the function the loop is in
012D449A  lea         ebx,[ebx]  

I am expecting the assembly code not to generate a dword ptr where I used register keyword.

So, How would I know if it’s possible for compiler to use a register and What should I do to force the compiler to read/write directly from/to registers.

  • 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-15T13:11:03+00:00Added an answer on June 15, 2026 at 1:11 pm

    In your case the compiler will most likely use a register anyway if you supply the right optimization options.

    In general, the only way to force a variable into a register is to use inline assembly.

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

Sidebar

Related Questions

i have this vb.net code where i use foreach to loop through check boxes
In a .NET code, I have a loop that takes all .wav files from
I have a this asp.net page which upon first time load: 1: Make a
in a ASP.NET application (MVC) I have a foreach loop that loops through a
I have a loop in razor which generates a template a number of times.
I have a bunch of code here -- http://jsfiddle.net/gDX3d/ A nice guy helped me
In my application, I want to have a polling loop which blocks on a
in my asp.net mark up I have a foreach loop that iterates through a
I have an aplication that loads many asp.net pages and in every loop I
I have an asp.net website which contains a Thread that fetches some data from

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.