Thread: IJVM question

  1. #1
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149

    IJVM question

    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.
    Code:
    geta6:	IADD
    	IADD
    	IADD
    	IADD
    	ISTORE a
    	GOTO return2
    So it would be something like:
    Code:
    geta6: if no more numbers to be added (at the bottom number of the stack)
                        return
                else IADD
                GOTO geta6
    I can't figure out how to make the loop in this language.

    Any help would be appreciated.


    Thanks
    IDE - Visual Studio 2005
    Windows XP Pro

  2. #2
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149
    Nevermind, i figured it out.
    IDE - Visual Studio 2005
    Windows XP Pro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM