Go Down

Topic: Code size difference (Read 502 times) previous topic - next topic

fiddler

These 2 bits of code toggles an output, but code 1 is 68 bytes smaller than code 2 when compiled.

Why is there so much difference ?

Kim


Code 1 (smaller):
//*****************************************
void  HeartBeat(void)  
{
 static byte state;      // private variable declared
 if (state>0)  {  
   digitalWrite(Heartbeat,HIGH);
   state= 0;
   delay(100);
 }
 else  {  
   digitalWrite(Heartbeat,LOW);
   state= 1;
   delay(100);
 }
 return;  
}
//********************************************



Code 2 (bigger):
//******************************************
void  HeartBeat(void)  
{
 static boolean state;      // private variable declared here
 
 digitalWrite(Heartbeat,state);
 state=!state;                   //toggle output state
 delay(100);

 return;  
}

fiddler

Okay, I guess I should look at the assembly listing as well.

fiddler

Spoke to soon.
When I press shift and click compile, all it does is compile normally.
I cannot see any assembly code

Any suggestions ?

Using Arduino V1 on Ubuntu

PaulS

Prior to 1.0, holding the shift key triggered verbose output. Now, it is a setting on the preferences panel.

fiddler

Okay, changed the setting in preferences to show verbose output during compilation.
But I can only see object files, which I cannot read with my editor

Hmm, any suggestions ?

Kim

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

fiddler

#6
Aug 26, 2012, 10:40 am Last Edit: Aug 26, 2012, 10:45 am by fiddler Reason: 1
Thanks
Didn't know that Linux came with a built in disassembler :-)
Command line only, tho. More stuff to remember.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy