// Scrivere un programma IJVM con il metodo main e due metodi exp(x, y). // Il main si deve occupare di chiamare il metodo exp con parametri attuali x = 3 e y = 5. // e di salvare il risultato in una variabile r. // Il metodo exp ha il seguente prototipo: // exp(x, y){ // z = 0 // for (i = 0; i < x + y; i++){ // if (i > x) // z = z + 3i // } // return z // } .constant OBJREF 0x40 .end-constant .main .var r .end-var LDC_W OBJREF BIPUSH 0x3 BIPUSH 0x5 INVOKEVIRTUAL exp ISTORE r HALT .end-main .method exp(x,y) .var z i .end-var BIPUSH 0x0 ISTORE i BIPUSH 0x0 ISTORE z control: ILOAD x ILOAD y IADD ILOAD i ISUB DUP IFEQ end IFLT end ILOAD i ILOAD x ISUB DUP IFLT continue IFEQ continue ILOAD z ILOAD i DUP DUP IADD IADD IADD ISTORE z continue: IINC i 0x1 GOTO control end: ILOAD z IRETURN .end-method