View previous topic :: View next topic |
Author |
Message |
knickohr
Joined: 24 Jan 2007 Posts: 97 Location: Germany
|
Posted: Sun Feb 24, 2008 9:43 pm Post subject: BASCOM 1.11.9.1 ROMIMAGE 20 Bytes bigger |
|
|
Hello,
just downloaded the new BASCOM-Version and compiled my old programs. The ROMIMAGE is now 20 Bytes bigger, why ?
"Optimize Code" is on.
It's only 20 Bytes, but a few programs will now not fit in the Chip
Thomas |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Mon Feb 25, 2008 4:06 am Post subject: |
|
|
If the compiler is changed to improve code generation / take out bugs / add extra features for newer chips, then you can expect compiled code to be different, sometimes radically. If the code works with the old compile, then just continue to use it. Just gives you headaches for code maintenance. One option many people use is to keep a complete install of the older compiler, plus all source code and generated object code as a separate disk folder or on CDrom. Them you can always revert. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 8:59 pm Post subject: |
|
|
I have the same problem! In one area, it is a tad over 99% with 1.11.9 with the newer it is over 101%.
Really makes life challenging.... Especially after working to reduce the size already to fit.
Is there any way to adjust this???
Tim |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Wed Feb 27, 2008 9:22 pm Post subject: |
|
|
TSEYFARTH wrote: | Is there any way to adjust this??? |
Hi Tim,
Just fire the programmer! How do you maintain a product
if you ship it with 1% of program space left?
Best regards,
Luciano |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 10:07 pm Post subject: |
|
|
I'd love to do that
I've asked, received and tried a bunch of tricks to reduce the size - which it did (thanks to suggestions from the forum).
The project is done at this point - would be nice for future maintenance (and of course possible bug fixes) to be able to use the most current IDE...
Is there any way to fix this via a setting in the IDE???
Tim |
|
Back to top |
|
|
knickohr
Joined: 24 Jan 2007 Posts: 97 Location: Germany
|
Posted: Wed Feb 27, 2008 10:13 pm Post subject: |
|
|
Hi Tim,
try to optimize your code !
For example :
if a=1 and b=2 then
...
end if
Optimized :
if a=1 then
if b=2 then
....
end if
end if
Will get 6 Bytes
Example 2 :
if c=3 then
d=0
end if
Optimized :
if c=3 then d=0
Will get another 2 Bytes
Example 3 :
If you use the Date="..." or Time="..." command, try to set the date or time in another way like _day=5 or so. The date and time commands are byte-wasting.
Thomas |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 10:29 pm Post subject: |
|
|
I've used other techniques to optimize, but dont think I have used your ideas (I have to check it has been a while...
However, why wouldnt the compiler compile the same in either case of?
Example 2 :
if c=3 then
d=0
end if
Optimized :
if c=3 then d=0
I dont understand why it wouldn't even with select case statemets too act the same. I have seen where it take more clock cycles to execute which again, to me, does not make sense but I am also not anywhere close to the level of a programmer who makes compilers!
Tim |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Wed Feb 27, 2008 10:45 pm Post subject: |
|
|
Quote: | I have the same problem! In one area, it is a tad over 99% with 1.11.9 with the newer it is over 101%.
Really makes life challenging.... Especially after working to reduce the size already to fit.
Is there any way to adjust this??? |
Tim, you are sooooo funny!
You have a massive case of string-itise and totally wore out the confines of an m128 (which i've never done). You've moved to a bigger chip and wiped out that space too! HA!
In time you'll have your alarm system requiring a dual core intel with 4 GB memory
Please don't thank me for my advice, i know where your heart would be at in this moment and can improvise the 4-letter words.
Last edited by DToolan on Wed Feb 27, 2008 10:54 pm; edited 2 times in total |
|
Back to top |
|
|
knickohr
Joined: 24 Jan 2007 Posts: 97 Location: Germany
|
Posted: Wed Feb 27, 2008 10:46 pm Post subject: |
|
|
Tim, I don't know the answer too. The answer kows the programmer of the compiler.
Another Example :
a=chr(32) will waste also bytes, try to type a=" ". If it is possible, search the correct character in your code-table, copy and paste it in your code.
What other code-optimizing-tricks do you use ?
Thomas |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 10:55 pm Post subject: |
|
|
DToolan you are talking like a real Homer!
This is a mega48 not 1281. There are no strings whatsoever in the program.
Sure wish you'd chime in helpfully without the undeserved shots.
tim |
|
Back to top |
|
|
DToolan
Joined: 14 Aug 2004 Posts: 1384 Location: Dallas / Fort Worth, Texas (USA)
|
Posted: Wed Feb 27, 2008 10:59 pm Post subject: |
|
|
Quote: | This is a mega48 not 1281. |
Tim, now you impress me... good job. |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 11:05 pm Post subject: |
|
|
Thomas
your nesting of the AND's worked (at least to reduce size I have not tested yet). I had 4 places where at least 1 AND was used and by nesting them, it reduced the compiled size by 2% to 97% on the 1.11.9.0 version.
I'll look for a few others too...
But, it would be nice if the variances were not there due to compilation.
Anyway back to work and thank you all!
Tim |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 11:11 pm Post subject: |
|
|
Thomas
Quote: |
What other code-optimizing-tricks do you use ?
|
Mostly getting rid of case statements (although I really like these for readability) whereever possible. I have found however that swapping case statements for if then else do not always reduce code size. Although unsure, I have been told that the number of clock cycles goes up to execute case over if then.
I also will preset varabiles to some default and only have them change if the criteria is met.
x=0
if y=1 then x=1
rather than
if y=1 then
x=1
else
x=0
end if
I am really not too good at the uC programming but was forced to learn and make it happen - hence the shots from Homer
Am getting better but still have a LONG way to go!
Tim |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Wed Feb 27, 2008 11:21 pm Post subject: |
|
|
One more item that makes the code smaller, but less readable (in my opinion) is getting rid of any un-necessary Subs. For example, I like to use a start up sub. This is really not necessary since it could go before the main loop. In the case of my 1281 where I am using only 11% of the program space, it can stay. But in the case of the MEGA48, it was not used.
Tim |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Thu Feb 28, 2008 12:15 am Post subject: |
|
|
Any program where you use a Sub/Function only once should be reduced to in-line code. And you can gain more space even for multiple calls if you can use a Gosub rather than a Sub. Yes you have to use global variables, which can be a nuisance, but you still save space, particularly if you pass many parameters in the call. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|