This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Query about Function Argument and Memory Allocation

#include<reg51.h>
void fun(char,int,long);
main()
{
step 1 fun(0xdd,0xaabb,0xfedcba);
}

step 2 void fun(char cc,int ii,long ll)
{	int i=0xabcd;
	char c=0x77;
	long l=0xabcdef;
	while(1);
	return;
}
 

I am runing, the above code, one step at a time.

step 1. The function fun() is being called and in the internal memory location, 0x04 and 0x05, the int data 0xAABB is stored and in memory location, 0x07, the char data 0xDD is stored and long data 0xFEDCBA is stored at the location 0x0C, 0x0D and 0x0E.

step 2. Now the function declaration is executed and data 0xDD is stored at memory location 0x08 and data 0xAABB is stored at memory location 0x09 and 0x0A.

My query is, why are the function arguments, char data[0xDD] and int data[0xAABB], stored twice in memory???

Wat is the use of it? And is there a way to avoid it?

To view the .JPEG picture of the source file with the memory map [during runtime] under Keil Cx51, click on the link below and download the 91Kb .JPEG file....... <\b>

http://s44.yousendit.com/d.aspx?id=1IZ24LT9B3XBS2F44P5X5EANSP

0