Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/08/11 07:22
Modified:
  06/08/11 07:27

Read: times


 
#182534 - Compiler variations??
I've moved somewhat ahead with my 89S52 based clock using 2x16 LCD & DS1307.
Now that time setting part is in progress, I've found something which I want to share & get myself corrected if there is something wrong with code itself.

I've inserted .LST file parts where anomalies were observed.

...==========================================================================
       1 ;--------------------------------------------------------
       2 ; File Created by SDCC : free open source ANSI-C Compiler
       3 ; Version 3.0.0 #6037 (Oct 31 2010) (MINGW32)
                              
==========================================================================
[1]
                           2442 ;	Test9.c:461: if(up_pressed)
   0ABE 30 85 99           2443 	jnb	_P0_5,00144$
                           2444 ;	Test9.c:463: if(dn_pressed)
   0AC1 A2 86              2445 	mov	c,_P0_6
                           2446 ;	Test9.c:467: dn2:          if (dn_pressed)
   0AC3                    2447 00157$:
   0AC3 20 86 63           2448 	jb	_P0_6,00169$

|        ||           ||     ||             ||                   ||     ||

[2]

                           2502 ;	Test9.c:483: if(up_pressed)
   0B20 20 85 03           2503 	jb	_P0_5,00303$
   0B23 02s0Ar5A           2504 	ljmp	00144$
   0B26                    2505 00303$:
                           2506 ;	Test9.c:485: if(dn_pressed)
   0B26 30 86 9A           2507 	jnb	_P0_6,00157$

|        ||           ||     ||             ||                   ||     ||

[3] 

                          2686 ;	Test9.c:540: if(up_pressed)
   0C68 30 85 91           2687 	jnb	_P0_5,00175$
                           2688 ;	Test9.c:542: if(dn_pressed)
   0C6B A2 86              2689 	mov	c,_P0_6
                           2690 ;	Test9.c:546: dn3:          if (dn_pressed)
   0C6D                    2691 00188$:
   0C6D 20 86 6B           2692 	jb	_P0_6,00200$

|        ||           ||     ||             ||                   ||     ||

 


In part[2]
if(dn_pressed) gives jnb P0.6 ; which is as expected
whereas in part [1] & [3]
if(dn_pressed) is giving mov c, P0.6 ; which is not expected.

Same code is used at all the three places.
Can somebody help & point out the problem here.

Sandy




List of 17 messages in thread
TopicAuthorDate
Compiler variations??            01/01/70 00:00      
   Fundamental philosophy of High-Level Languges (HLL)            01/01/70 00:00      
      C code            01/01/70 00:00      
         and so what            01/01/70 00:00      
         Stop wondering about the compiler output            01/01/70 00:00      
            Very nice to learn this important matter            01/01/70 00:00      
         Exactly what you wrote            01/01/70 00:00      
            volatile sbit may be the problem            01/01/70 00:00      
               read up on (not) volatile            01/01/70 00:00      
               Look at my profile            01/01/70 00:00      
                  Not offence intended            01/01/70 00:00      
                     defining P0_6 so that compiler doesn't treat it as volatile            01/01/70 00:00      
                        Skip the goto - almost always exists beautiful rewrites            01/01/70 00:00      
                           Goto really is a bastard code construct            01/01/70 00:00      
                              and therefore ...            01/01/70 00:00      
                                 Will come back with modified code            01/01/70 00:00      
                           Wonderful as always!            01/01/70 00:00      

Back to Subject List