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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:36+00:00 2026-05-26T04:58:36+00:00

I was wondering if local variables in assembly are faster than the global variables

  • 0

I was wondering if local variables in assembly are faster than the global variables that we use. The context for this is that I am learning some 2d animation using the win32 api, from a book. The author uses a function to initialize(Creation,registration, showing and updating of the window) the main window for the program. I wrote that function in asm(just to practice some asm). So, I was wondering if there is any performance advantage involved, since in the asm function i used, the WNDCLASSEX structure was created locally(in stack). I know that the local variables in assembly are supposed to be faster, but having gone through the disassembly for another program(entirely in cpp), I noticed that the compiler creates the WNDCLASSEX locally as well. This confused me about the topic. So i want to know if there is any difference in performance between the asm code and C++ code.

Devjeet

  • 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-26T04:58:36+00:00Added an answer on May 26, 2026 at 4:58 am

    The top of the stack is touched by a lot of code. That means the the top of the stack is usually in CPU cache. Accessing this would be faster than accessing other memory areas (from .bss, etc).

    But for a function like CreateWindow which is called only a few times per program this doesn’t really matter. The difference is less than a a few hundred CPU cycles. For other parts of the code the difference might be more noticeable. But an important thing to note is that if you’re doing the same thing repeatedly with the same piece of data that data too will end up in CPU cache and thus the performance difference would be negated.

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

Sidebar

Related Questions

SQL Server 2008 I have a query with several local variables that does some
wondering if some of you know what javascript framework facebook is using ? Thanks
I was wondering how I could create component-scoped beans, or so-to-say, local variables inside
Something like this (yes, this doesn't deal with some edge cases - that's not
Just wondering if there's a way to access local variables in rspec without turning
So I have this compiler class that compiles some .mjava files but others it
I'm wondering if anyone if aware of a language that has support for variables
I am wondering do all the local variables become static if we declare them
Possible Duplicate: Where are static variables stored (in C/C++)? I am wondering where global
I have a web service that returns some XML data using a RESTful API.

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.