Pages: [1]   Go Down
Author Topic: Code size difference  (Read 335 times)
0 Members and 1 Guest are viewing this topic.
NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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;  
}
Logged

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24317
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Avr-objdump
Logged

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

NZ
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks
Didn't know that Linux came with a built in disassembler :-)
Command line only, tho. More stuff to remember.
« Last Edit: August 26, 2012, 03:45:11 am by fiddler » Logged

Pages: [1]   Go Up
Jump to: