Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

BASCOM 1.11.9.1 ROMIMAGE 20 Bytes bigger
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
knickohr

Bascom Member



Joined: 24 Jan 2007
Posts: 97
Location: Germany

germany.gif
PostPosted: Sun Feb 24, 2008 9:43 pm    Post subject: BASCOM 1.11.9.1 ROMIMAGE 20 Bytes bigger Reply with quote

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 Sad

Thomas
Back to top
View user's profile Visit poster's website
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2477
Location: Queensland

australia.gif
PostPosted: Mon Feb 25, 2008 4:06 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 8:59 pm    Post subject: Reply with 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
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Wed Feb 27, 2008 9:22 pm    Post subject: Reply with quote

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
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 10:07 pm    Post subject: Reply with quote

I'd love to do that Smile

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
View user's profile
knickohr

Bascom Member



Joined: 24 Jan 2007
Posts: 97
Location: Germany

germany.gif
PostPosted: Wed Feb 27, 2008 10:13 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 10:29 pm    Post subject: Reply with quote

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
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Wed Feb 27, 2008 10:45 pm    Post subject: Reply with quote

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! Wink

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! Smile

In time you'll have your alarm system requiring a dual core intel with 4 GB memory Smile

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. Wink


Last edited by DToolan on Wed Feb 27, 2008 10:54 pm; edited 2 times in total
Back to top
View user's profile Yahoo Messenger
knickohr

Bascom Member



Joined: 24 Jan 2007
Posts: 97
Location: Germany

germany.gif
PostPosted: Wed Feb 27, 2008 10:46 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 10:55 pm    Post subject: Reply with quote

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
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Wed Feb 27, 2008 10:59 pm    Post subject: Reply with quote

Quote:
This is a mega48 not 1281.

Tim, now you impress me... good job.
Back to top
View user's profile Yahoo Messenger
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 11:05 pm    Post subject: Reply with quote

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
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 11:11 pm    Post subject: Reply with quote

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
Evil or Very Mad

Am getting better but still have a LONG way to go!

Tim
Back to top
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1053

usa.gif
PostPosted: Wed Feb 27, 2008 11:21 pm    Post subject: Reply with quote

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
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2477
Location: Queensland

australia.gif
PostPosted: Thu Feb 28, 2008 12:15 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum