Question: Write equivalent MARIE assembly program for the following c++ program : #include using namespace std; int main() { int num = 0; int quot =

Write equivalent MARIE assembly program for the following c++ program :

#include using namespace std;

int main() {

int num = 0; int quot = 0; // quotent; divide by 2 int rem = 0; // remainder; divide by 2 int zero = 0; int one = 1; int two = 2;

// Input // Store num cin >> num; // input (in decimal)

// keep subtracting 2 while 0 or positive // quotient = count how many time you can subtract // remainder = 0 if num == 0 at the end while (true) { num = num - two; if (num >= 0) { quot = quot + one; } if (num < 0 || num == 0) { break; } }

if (num == 0) { rem = zero; } else { rem = one; }

// Output display with 'linefeed' cout << quot << endl; cout << rem << endl;

return 0; }

Make sure to add the equivalent C++ statement as comments for every 2 MARIE instructions. The program should complete within 1 minute when tested with an input of 200 (in decimal) or smaller.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!