Exercise 5      Name       ____________________   Points __/13

Document last modified: 
 

Data

Addr    Variable 
00                     0           
01        i            2
02        y            1
03        x            23
04                     -4
05                     9
06                     2
07        z            7
08        n            4

Give the Hypothetical Machine code for the following using data defined above. Assume each instruction execution is independent of the others.

  1. (1) y = y + z
  2. (1) z = z + 1                        
  3. (1) y = x[i] 
  4. (1) z = x[1]
  5. (1) read z;

Complete the Hypothetical Machine code program by encoding the following algorithm part. Use the data part from above.

  1. (8) i = 0;
         y = 0;
         do { 
           read z;
           y = y + z;
           i++; 
         } while (i < n);
         z = y / n;
         print z;

Data for read instruction:
            3.5
            2.4
            7.8
            1.3