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

Possible compilator bug???

Hi,
i need to XOR couple of bytes. Im try to do it by this way:

	 	pozice =0;
  		adresa = 0x0A;
		data = 0x3F;
		data2 = 0x10;
		xdat =adresa ^ data ^ data2;
		//xdat = 0x25;

but the output is not XOR of this data.
I also find another interest thing:
	 	pozice =0;
  		adresa = 0x0A;
		data = 0x3F;
		data2 = 0x10;
		xdat = adresa;
		xdat ^= data ;
		xdat ^= data2;//adresa ^ data ^ data2;
		xdat = 0x25;
In xdat isnt 0x25. I currently havent JTAG and RS232 working, so i dont know the value of xdat, but im %100 sure that is not 0x25. If I commented xdat = adresa, xdat ^= data(2).... its working. Otherwise this way of xoring data its not working also.

Jirka

Parents
  • I would think it is a debugger issue.

    It takes YEARS of using whatever debugger before you can assume that you know if the displayed value is valid to an extent great enough hat you should not doublecheck (try to see the value by other mens) before you out of hand decide that the code (or compiler) is wrong. For instance, sometimes the only way to see what C provides to a function is by debugging in the assembler.

    I, still, after who knows how many years, occasionally (dis)believe one of my debuggers when I should not.

    Erik

    PS in the above 'debugger' refer to any debugger, ICE, JTAG, simulator or whatever.

Reply
  • I would think it is a debugger issue.

    It takes YEARS of using whatever debugger before you can assume that you know if the displayed value is valid to an extent great enough hat you should not doublecheck (try to see the value by other mens) before you out of hand decide that the code (or compiler) is wrong. For instance, sometimes the only way to see what C provides to a function is by debugging in the assembler.

    I, still, after who knows how many years, occasionally (dis)believe one of my debuggers when I should not.

    Erik

    PS in the above 'debugger' refer to any debugger, ICE, JTAG, simulator or whatever.

Children
  • I tried simulate it and it seems workikg well. Then tell me why this works:

    		adresa = 0x0A;
    		data = 0x3F;
    		data2 = 0x10;
    		xdat = 0x25 ;
    

    and this not:
      		adresa = 0x0A;
    		data = 0x3F;
    		data2 = 0x10;
    		xdat = adresa;
    		xdat ^= data ;
    		xdat ^= data2;
    		xdat = 0x25;
    

    and this also not:
      		adresa = 0x0A;
    		data = 0x3F;
    		data2 = 0x10;
    		xdat = adresa ^ data ^ data2;
    

    Im beginer in ARM7, but this may work. I tried simulate this also in C# ( only plain code) and it also works. If you want I can send you my project, just give me your mail or send me mail to drakulaj@seznam.cz .

    Jirka

  • It only takes about 5 minutes to see that what the Keil debugger is displaying and what is actually happening do not match up (This has been since the switch to realview). The compiler seems to be generating valid code for me. The (current) debugger is always confused as to where local variables and parameter are and where a line compiled code starts and ends in assembly. This is even with optimizations on the lowest setting.

  • OK I made copule other test and diasslembly ferquency output and i find this:

    xdat = (data2 ^ data ^ adresa);
    

    deletes values in data2, data, adresa
    ( this values are in output zeros ) and xor is OK . If i use this:

      		adresa = 0x0A;
    		data = 0x3F;
    		data2 = 0x90;
    
    		xdat = (data2 ^ data ^ adresa);
    		adresa = 0x0A;
    		data = 0x3F;
    		data2 = 0x90;
    
    

    its working. So whats wrong?

  • OK i fing my bug - just type unsigned char volatile data ..... Its my bug.

    Jirka