We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
1.I have defined a function as follow: char str_cmp(const char*str1,const char*str2); but the two parameter str1 and str2 have the same value(0x1206) after enter this function although they are different(0x0100,0x1206) in the caller. 2.another problem is the compiler locate the explicit xdata parameter in data memory,as follow: int xdata i; i is located in 0x06 and I can't change the value of i with the following statment,i=10; but if I define i as long,it is located in xdata.
2.another problem is the compiler locate the explicit xdata parameter in data memory,as follow: int xdata i; i is located in 0x06 and I can't change the value of i with the following statment,i=10; but if I define i as long,it is located in xdata. By default, the compiler passes up to 3 function arguments in registers. This is much faster than passing the arguments in fixed memory locations. If you don't want the compiler to use registers for your parameters take a look at the NOREGPARMS dirctive. This will slow down your program and increase the size of the code nicely. Jon
Please use the < pre > and < /pre > HTML tags when posting souce code. Regarding your first question. Have you taken into account the fact that these are generic pointers? Just a thought. How are you getting at the value of the variables, the C51 optimisations can leave the debugger confused. To be sure of what is going on, you may need to step through each disasembly instruction. Your question says: 2.another problem is the compiler locate the explicit xdata parameter in data memory,as follow: int xdata i; i is located in 0x06 and I can't change the value of i with the following statment,i=10; but if I define i as long,it is located in xdata. However, in your source code you have:
char str_cmp(const char* str1,const char* str2) { int i=0; .... }
It's ok after I used the directive NOREGPARMS. Thanks to everyone.