Homework Solution: Give the Java statement that produced the following JVM assembly code and explain:…

    Give the Java statement that produced the following JVM assembly code and explain: ILOAD k ILOAD n IADD IPUSH 16 IADD IDUP ISUB ISTORE m

    Expert Answer

     
    Answer: i=(j-n+7)*2;

    Give the Java announcement that manufactured the subjoined JVM parterre statute and explain:

    ILOAD k

    ILOAD n

    IADD

    IPUSH 16

    IADD

    IDUP

    ISUB

    ISTORE m

    Expert Rejoinder

     

    Answer: i=(j-n+7)*2;
    The announcement i=(j-n+7)+(j-n+7); was too pleasurable although the Java
    compiler would probably not attributable attributable attributable appliance such an optimizaton.

    BIPUSH Value Cemats
    • BIPUSH value
    Value is individual byte
    Value is decimal by default
    • BIPUSH 32
    Leading 0 ce octal number
    • BIPUSH 032
    Leading 0x ce hexadecimal number
    • BIPUSH 0x32
    Leading ‘ ce ASCII characters

    • BIPUSH ‘M

    “Simple” Addition
    i = 3; j = 4; n = i + j;
    BIPUSH 3
    ISTORE i
    BIPUSH 4
    ISTORE j
    ILOAD i
    ILOAD j
    IADD
    ISTORE n
    HALT

    “Simple” Subtraction
    i = 3; j = 4; n = j – i;
    BIPUSH 3
    ISTORE i
    BIPUSH 4
    ISTORE j
    ILOAD j
    ILOAD i
    ISUB
    ISTORE n
    HALT