QuestionQuestion

Convert the following C++ program into an x86 assembly language program.

#include <iostream>

using namespace std;

// Tests for algorithm correctness
// -------------------------------
// 1 gives output "1 3 7 15 31 63 127 255 511 1023 2047"
// 2 gives output "2 5 11 23 47 95 191 383 767 1535 3071"
// 3 gives output "3 7 15 31 63 127 255 511 1023 2047 4095"
// 5 gives output "5 11 23 47 95 191 383 767 1535 3071 6143"

// Global variables
int X;
int I;

int main()
{
cout << "Enter starting value: ";
cin >> X;

cout << X;
cout << " ";

for (I = 1; I <= 10; ++I)
{
if ((X & 1) == 0)
{
X = X + 3;
}
else
{
X = (2 * X) + 1;
}
cout << X << " ";
}
cout << endl;

system("PAUSE");
}

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

INCLUDE

ExitProcess proto, dwExitCode:dword

.data

   ; We reserve memory space to store the variables
x dw 0;
    i dw 1;
   
    message1 db "Enter starting value: ", 0
    message2 db " ", 0; This is a string composed of a single character, a simple space...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$25.00 $12.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats