Translate the following C code segment into Mic1 IJVM machin
Solution
Solution for I & II:
Mic-1 IJVM instructions
It has to be noted that every IJVM program must contain a main method. So let us define i,j and k as variables in the main method. Since we have assumed that the values are 3,2, and 2 respectively, let us define them as local variables.
.main
.var
    i
    j
    k
 .end-var
 Thus IJVM instructions along with the machine instructions are as follows:
IJVM inst. Machine instructions(Hex code)
ILOAD i       0x15 0x01
 ILOAD j       0x15 0x02
 ISUB 0x64
 ISTORE i    0x36 0x01
 ILOAD i 0x15 0x01
 BIPUSH 6    0x10 0x06
 IF_ICMPEQ L1 0x09F 0x00 0x0D
 ILOAD i    0x15 0x01
 ILOAD j    0x15 0x02
 IAND        0x7E
 ILOAD k    0x15 0x03
 ISTORE k    0x36 0x03
 loop2:
 ILOAD i    0x15 0x01
 ILOAD j    0x15 0x02
 IOR        0x80
 ILOAD k    0x15 0x03
 ISTORE k    0x36 0x03
 III. Time clock cycles needed:
There are 104 microinstructions. With a clock to 400MHz, every microinstruction employs a time:
duration of 1 microinstruction =1/(400x(NNN)NNN-NNN=2.5ns
SO the total execution time i = 2.5*104 = 260ns

