Exercise 4            Name       _____________________    Points ___/21

Translate the following from C++ fragments to corresponding structured Assembler. Assume that Ax, Bx, Ah, Al are the normal register definitions, i , j and sum are defined as words. Use Getdec, Getdec$, Putdec, and Putdec$ for input and output.

1. (3)    if (i < Ax) {
            Ax++;
            cout << Ax;
          }
 
 
 
 

2. (5)    if (i < Ax) {
            Ax++;
            cout << Ax;
          }
          else {
            Ax--;
            cout << Ax;
          }
 
 
 

3. (3)    while (Ax > 0) {
            Ax = Ax / 3;
            cout << Ax;
          }
 
 
 
 

4. (5)    for (i=0; i<10; i++)
            for (j=10; j>5; j--) {
                Ax = i*j;
                cout << Ax;
            }
 
 
 
 
 
 

5. (5)    sum = 0;
          do {
            cin >> Ax;
            if (Ax < 0)
                Ax = -Ax;
            sum = sum + Ax;
          while (Ax != 0);


Document last modified: