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
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.
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.
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
Re: Ran out of space need help reducing code size
Is there no way you could simply use a device with more FLASH?
Re: Ran out of space need help reducing code size
Quote:
Originally Posted by
rsocor01
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.