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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:07:51+00:00 2026-05-31T23:07:51+00:00

I wrote this simple C code and compiled it using Visual Studio 2010, with

  • 0

I wrote this simple C code and compiled it using Visual Studio 2010, with assembler output.

int main(){
    int x=1;
    int y=2;
    int z=x+y;
    return 0;
}  

And this is the assembly output..

; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01 

    TITLE   foobar.cpp
    .686P
    .XMM
    include listing.inc
    .model  flat

INCLUDELIB OLDNAMES

EXTRN   @__security_check_cookie@4:PROC
PUBLIC  _main
; Function compile flags: /Ogtp
; File foobar.cpp
;   COMDAT _main
_TEXT   SEGMENT
_main   PROC                        ; COMDAT

; 2    :    int x=1;
; 3    :    int y=2;
; 4    :    int z=x+y;
; 5    :    return 0;

    xor eax, eax

; 6    : }

    ret 0
_main   ENDP
_TEXT   ENDS
END

Is this complete? I do not see any ADD statement. What compiler can be used to compile it?

  • 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-31T23:07:52+00:00Added an answer on May 31, 2026 at 11:07 pm

    Since your code doesn’t do anything with those values, the compiler has optimized most of it out. As Carl mentioned, all that remains is the xor eax, eax which is zeroing eax, the register that the return value is placed.

    Even if you were to printf("%d", z), your result z is a compile-time constant (3), and that is all you would see in the assembly listing.

    What you can do is disable optimizations in your project C++ properties, and you should see your expected assembly. Also, building in Release mode should minimize the extra debug stuff you see in the asm.

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

Sidebar

Related Questions

I've wrote this simple piece of code. And I have a slight problem with
I am trying to write a simple tool using Shoes. This will indent code
I try to load image with processing.js using CoffeeScript and write this simple code:
I’m trying to write a basic ASP.NET form (using Visual Studio 2010) to submit
So I wrote this simple console app to aid in my question asking. What
I've just started learning about parsing, and I wrote this simple parser in Haskell
I'm trying to retrieve folders name from a zip file. I wrote this simple
I'm write a simple graphic-based program in Assembly for learning purpose; for this, I
I want to write some simple code using DDK - but i don't know
I am new to bit manipulations tricks and I wrote a simple code 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.