I could not find an explanation for an observation given below.
1)When I declared bits like bit AM,fg_chat,pumpoff=0;pumpon=0,mode=0; bit PMP_flag = 1,buzzer=0,pumpon_flag=0; bit xmitempty,flash1,response_received=0,response_delayed=0,sms_flag; bit oht_red,oht_rg,glr_red,glr_rg;
my program data size was 74.3 bytes and code size 2179(there are many other variables also) but when I declared like bit AM,fg_chat,pumpoff=0;pumpon=0,mode=0, PMP_flag = 1,buzzer=0,pumpon_flag=0, xmitempty,flash1,response_received=0,response_delayed=0,sms_flag, oht_red,oht_rg,glr_red,glr_rg; the data size increased to 96.7 bytes and code size 2387. I use 89S52 uC.
Why this happens? What is difference between these?
That's one reason why it's generally best not to have multiple declarations in a single statement! agreed, but the REAL reason should be I would also encourage you to make it a habit to comment every definition
Erik
"comment every definition"
Just for the sake of completeness, it is still possible to do that; eg:
bit xmitempty, // Explain the purpose of this variable flash1, // Explain the purpose of this variable response_received=0, // Explain the purpose of this variable response_delayed =0, // Explain the purpose of this variable sms_flag; // Explain the purpose of this variable
But that seems entirely pointless to me!
I prefer to repeat the type for each variable, with one variable/line.
If I do "grep" for a variable, I want the printout to also show the data type.
Indeed - and the comment!
In fact, with some tools, when you mouse over a variable name, it will show the definition line - including any comment.
Let me ask one more doubt I use serial communication and T0 interrupt . I write the functions as below
void Scc0InterruptHandler() interrupt SIO_VECTOR using 1 { }
int0Delay() interrupt TF0_VECTOR using 2 { }
But while debugging, it is noted that the first ISR is using register bank 1 but the second ISR using register bank 0 even though it has to use 2 as per the program. Kindly comment.