What's the difference between const unsigned int & char or unsigned int & char?

Status
Not open for further replies.
Re: C code


Hai..

Do you have smart 8051 compiler can you send the installer to my mail (tangbc05@yahoo.com)..please.., may be my compiller is not full version...
Can you give example code for this because i still not understand very well "Try doing something useful with x and y, so the compiler can't just throw them away". Thank for your help....

My code is that simple:

Code:
#include <reg52.h>

void main(void)
{

	while(1)
	{
		unsigned int x, y; 

		for(x=0; x<=3; x++) 
		{ 
  			for(y=0; y<=120; y++); 
		}
	}
}

Is it any problem to my code....

Thank You..
 

Re: C code

I'm sorry, I don't have any 8051 compiler.

Your code is fine (except for that void main thing), however x and y do no useful work, so the compiler may simplify them, or remove them.

In this program I print x and y, so the compiler can't throw them away:
Code:
#include <stdio.h>

int main(void)
{
  unsigned int x, y;

  for(x=0; x<=3; x++)
  {
    for(y=0; y<=120; y++)
    printf("%d %d\n", x, y);
  }
  return 0;
}
 

Re: C code


Hi..

Sorry... i understand all ready but it only for pure C we can add "%d %d\n" but how about for Embedded C for 8051 compiler...

So, nevermind.. have any solution/method to simulate the time-delay or for-loop result for 8051 compiler

Thanks....
 

C code

Oh. Your 8051 compiler doesn't support printf(). I understand.

Time delay? Is that why you are writing loops that do nothing? Software delay loops can be very unpredictable, as you have seen! You should use the 8051's hardware timer. I don't know how to do that, but I'm sure there are other messages on this board.
 

Re: C code


Hai...

Do you know 8051 compiler got one debug call Performance Analyzer, do you know how to use it??

Thanks.....

Added after 1 hours 59 minutes:

Hi, Every One

Do you know how to use uVision Performance Analyzer: min time, max time, avg time, total time. %, count ??

Thanks
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…