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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:37:45+00:00 2026-06-15T00:37:45+00:00

I am trying to get into ASM concepts and while observing the disassembly generated

  • 0

I am trying to get into ASM concepts and while observing the disassembly generated by MSVC there`s something I cannot fully understand. Here is my test case:

#include <tchar.h>
#include <conio.h>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    int v1 = 1;
    int v2 = 2;
    int v3 = 3;
    int v4 = 4;
    int v5 = 5;
    int v6 = 6;
    int v7 = 7;
    int v8 = 8;
    int v9 = 9;
    int v10 = 10;
    int v11 = 11;
    int v12 = 12;
    int v13 = 13;
    int v14 = 14;
    int v15 = 15;
    int v16 = 16;

    int sum = v1+v2 * (v3+v4 * (v5+v6 * (v7+v8 * (v9+v10 * (v11+v12 * (v13+v14 * (v15+v16)))))));

    _getch();
    return 0;
}

which generates something like:

    mov eax, v1
    mov edx, v3
    mov ecx, v5
    mov ebx, v7
    mov esi, v9
    mov edi, v11 // all 6 available registers are filled
    mov dword ptr [ebp-60h), eax // free eax   <<<<<<
    mov eax, v15 // fill it again
    add eax, v16
    imul eax, v12
    (...)

So, my question is:
What does the compiler do at the line marked with “<<<<<<” ? My
guess is that it has created a variable to store the register value
in. Is looks it is on the stack as it uses the ebp, but is it
something like a “global variable”, or is it a variable in current
scope (frame) only?

Thanks in advance.

  • 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-15T00:37:46+00:00Added an answer on June 15, 2026 at 12:37 am

    MSVC will spill registers to the appropriate memory: to the stack when it’s spilling a register that held a variable with block scope, or to a fixed offset when the register held a global. At any point, the compiler knows which variables are in which register.

    You can’t spill local variables to global memory because there might an unpredictable number of them, due to threads and reentrancy. A compiler may be able to spill a global variable to a stack slot, temporarily, but this is quite complex in the presence of threads.

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

Sidebar

Related Questions

I'm trying to get into unit testing, but there's one thing bothering me. I
Just trying to get into JQueryMobile. I want to do something simple like putting
I've been trying to get into F# on and off for a while but
I'm trying to get into the habit of coding to an interface rather than
I'm just trying to get into the benefits of using CSS vs. tables, but
I'm currently trying to get into Java Web Development in general in Spring more
I am just trying to get into python, but I've found it very difficult
I'm trying to get into mobile UI Automation. I've run into an issue installing
I am trying to get into android development, after some reading i have settled
I'm just trying to get more into stl semantics, and converting old loops over

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.