I was wondering if anyone could help me with a question i have regarding an IJVM program i am working on. I think it is a very simple solution for anyone who knows the language well. I didn't know where to post my question, so i posted here.
I'm trying to add every number up to a number entered. (So, if you entered 5, it would add 0+1+2+3+4+5)
I can keep adding "IADD" and it will add as many numbers together as i have "IADD"s. But, i need to implement a loop, so it will keep adding the numbers until the bottom of the stack. But i can't figure out how to do this.
Here is how i am doing it without a loop. This will be 0+1+2+3+4 and will return 10. Since i don't know what number is going to be entered, i need to turn it into a loop.
So it would be something like:Code:geta6: IADD IADD IADD IADD ISTORE a GOTO return2
I can't figure out how to make the loop in this language.Code:geta6: if no more numbers to be added (at the bottom number of the stack) return else IADD GOTO geta6
Any help would be appreciated.
Thanks