//Scrivere un programma IJVM con il main e un metodo fun che riceve due parametri. //Il main dovrà chiamare fun con a = 5 e b = 2 e salvare il risultato in una variabile r. //Il metodo dovrà implementare: // //c = 0 // //if(a > b + 1) { // a = a + 3 // i = b // while (a >= i) { // c = c + (i * 2) // i = i * 3 // } // //} else { // i = a - 1 // while (b > i) { // c = i + (c * 2) // i = i + c // } //} // //return c .constant OBJREF 0x40 .end-constant .main .var r .end-var LDC_W OBJREF BIPUSH 0x5 BIPUSH 0x2 INVOKEVIRTUAL fun ISTORE r HALT .end-main .method fun(a, b) .var c i .end-var ILOAD a ILOAD b BIPUSH 0x1 IADD ISUB DUP IFLT else IFEQ else IINC a 3 ILOAD b ISTORE i while-if: ILOAD a ILOAD i ISUB IFLT end ILOAD c ILOAD i DUP IADD IADD ISTORE c ILOAD i DUP DUP IADD IADD ISTORE i GOTO while-if else: ILOAD a BIPUSH 0x1 ISUB ISTORE i while-else: ILOAD b ILOAD i ISUB DUP IFLT end IFEQ end ILOAD i ILOAD c DUP IADD IADD ISTORE c ILOAD i ILOAD c IADD ISTORE i GOTO while-else end: ILOAD c IRETURN .end-method