PDA

View Full Version : Ran out of space need help reducing code size



lockjawz
- 14th April 2011, 14:06
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


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

aratti
- 14th April 2011, 19:50
To start you can remove all the for/Next placing PAUSE =20. This is all I can see from your post.

Al.

Archangel
- 15th April 2011, 01:12
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.

rsocor01
- 15th April 2011, 02:46
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

Charles Linquis
- 15th April 2011, 04:48
Is there no way you could simply use a device with more FLASH?

lockjawz
- 15th April 2011, 13:16
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.