Ran out of space need help reducing code size


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2011
    Posts
    19

    Default Ran out of space need help reducing code size

    I dont have much time to do this project and i tried to program my chip the easy way(but very long). I cant do it this way because i my code size is to big. If there is any way of doing this a easier smaller way please let me know.

    I have a main loop for hours mins and seconds for chaning my time and then sub loops like 1s digits and 10s for the hour this takes way too much space.

    loopa is the counting loop

    Code:
    loophour:
    if num0=0 then
    hour=0
    for i=0 to 20
            pause 1     
        next i 
     goto loophour1s
     endif
     if num1=0 then
     hour=1
     for i=0 to 20
            pause 1     
        next i 
     goto loophour10s
    endif
    if numstar=0 then
        for i=0 to 20
            pause 1     
        next i
        goto loopa
    else
    goto loophour10s
    endif
    
    
    loophours10s:
    if num0=0 then
    hour=10
    for i=0 to 20
            pause 1
        next i
        goto loopmins
    endif
    if num1=0 then
    hour=11
    for i=0 to 20
            pause 1     
        next i
        goto loopmins 
    endif
    if numstar=0 then
        for i=0 to 20
            pause 1     
        next i
        goto loopa
    else
    goto loophour10s
    endif

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Ran out of space need help reducing code size

    To start you can remove all the for/Next placing PAUSE =20. This is all I can see from your post.

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Ran out of space need help reducing code size

    I have not done much programming in a year or so, and I am getting rusty . . . but as I remember, If Then GoTo s use up a lot of resources, try substituting select case routines instead, and for your mainloop use while / wend. Please Anyone correct me if I am wrong.
    Last edited by Archangel; - 15th April 2011 at 01:27. Reason: spell
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Ran out of space need help reducing code size

    Also, how are you declaring your variables? Are you declaring them as bytes or words? It makes a big difference what type of variables you use.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Ran out of space need help reducing code size

    Is there no way you could simply use a device with more FLASH?
    Charles Linquist

  6. #6
    Join Date
    Feb 2011
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Ran out of space need help reducing code size

    Quote Originally Posted by rsocor01 View Post
    Also, how are you declaring your variables? Are you declaring them as bytes or words? It makes a big difference what type of variables you use.

    Robert
    THANKS!
    had my var as a word thats why it was taking up so much space.
    Last edited by lockjawz; - 15th April 2011 at 13:22.

Members who have read this thread : 2

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts