Translate the following C code segment into Mic1 IJVM machin

Translate the following C++ code segment into Mic-1 IJVM machine language, assuming i, j, and k are the first, the second and third local variables, respectively. Translate the code segment in Mic-1 UVM instructions you derive above into machine instructions. Please use hexadecimals to represent machine language instructions. Assuming the initial values of the three local variables are i = 3, j = 2, k = 1, how long does a 4-GHz Mic-1 take to execute this C++ code segment? Give your answer in nanoseconds.

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

 Translate the following C++ code segment into Mic-1 IJVM machine language, assuming i, j, and k are the first, the second and third local variables, respective

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site