Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Debug and Release Binaries > "Arithmetic" Project: C/C++ Program

2.1. "Arithmetic" Project: C/C++ Program

Let's rewrite our "Arithmetic" program in C++. Corresponding assembly language instructions are put in comments:

int a, b;
int main(int argc, char* argv[])
{

        a = 1;         // mov [a], 1
        b = 1;         // mov [b], 1
        b = b + a;     // mov eax, [a]
                       // add [b], eax
        ++a;           // inc eax
                       // mov [a], eax
        b = a * b;     // imul [b]
                       // mov [b], eax
        // results: [a] = 2 and [b] = 4
        return 0;
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial