Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.
Re: C code

echo47 said:
Yes, a smart optimizing compiler won't bother generating any machine code that increments the variables, because it already knows their final values.

If you don't use x and y later in your program, then a smart compiler will remove all the machine code and memory storage for those variables, because they do no useful work.

I don't know how smart your 8051 compiler is. Maybe it optimizes some things but not others. That would explain the unexpected behavior you see in the debugger.

Try doing something useful with x and y, so the compiler can't just throw them away.

unsigned int and unsigned mean the same thing. I changed it by habit, without realizing that I had done it!

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

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

Your code is valid C, 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<=2; x++)
  {
    for(y=0; y<=5; y++)
    printf("%d %d\n", x, y);
  }
  return 0;
}

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

echo47 said:
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.

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top