Exercise 5a      Name       ____________________   Points __/13

Document last modified: 
 

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, assume each instruction execution is independent of the others.

  1. (1) y = y + z             +1020702
  2. (1) z = z + 1             +1070207           
  3. (1) y = x[i]                +6030102
  4. (1) z = x[1]               +6030207
  5. (1) read z;                 +8000007

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

  1. (8) i = 0;                                        +0000001
         y = 0;                                       +0000002
         do {                                          +8000007 
           read z;                                     +1020702
           y = y + z;                                 +7010802
           i++;                                         -2020807
         } while (i < n);                            -8070000
         z = y / n;
         print z;

Data for read instruction:
            3.5
            2.4
            7.8
            1.3