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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/10/11 10:48
Read: times


 
#180495 - Avoid the 'volatile'
Responding to: ???'s previous message
Looking at my 8051 standard header file:

#if defined (SDCC)			/* SDCC */
...
#define XBYTE ((unsigned char xdata *) 0) /* NOT volatile cos duff code */

 


You can normally access memory mapped peripherals with the XBYTE macro e.g.
#define lcd_status      XBYTE[LCD_PORT]
#define lcd_data        XBYTE[LCD_PORT+1]
#define lcd_ctl         XBYTE[LCD_PORT+3]

 


I have no idea why I added the above comment for SDCC, just that it is there.
The regular XBYTE macro uses volatile for other compilers.

I seldom use 8051, and my SDCC is elderly.
From a semantic point of view, you should use volatile.

You may prefer using different macros. For example
#define XMEM(ads) ((unsigned char xdata *) 0)[x] /* NOT volatile cos duff code */

 

or use the __at modifier in a different macro.

David.

List of 25 messages in thread
TopicAuthorDate
sdcc internal error / C syntax            01/01/70 00:00      
   legality of indexing NULL pointer            01/01/70 00:00      
      bug            01/01/70 00:00      
         version            01/01/70 00:00      
            version revisited            01/01/70 00:00      
               thank you            01/01/70 00:00      
                  Fixed            01/01/70 00:00      
                     no snapshot            01/01/70 00:00      
                        works            01/01/70 00:00      
                           0 is special - but so is NULL. indexing around NULL is bad            01/01/70 00:00      
                              No guarantee that a NULL pointer points to any memory            01/01/70 00:00      
            time            01/01/70 00:00      
               I know :-(            01/01/70 00:00      
       Use of __at ?            01/01/70 00:00      
         What is "that way"?            01/01/70 00:00      
            the antique version....            01/01/70 00:00      
            XBYTE macro            01/01/70 00:00      
               Okay, then the following definition...            01/01/70 00:00      
                  RE: David's remarks about volatility            01/01/70 00:00      
   Close, but no cigar            01/01/70 00:00      
   Avoid the 'volatile'            01/01/70 00:00      
      instead of offsetting...            01/01/70 00:00      
         Dereferencing a '_REG            01/01/70 00:00      
            I agree            01/01/70 00:00      
      Use of __at ? [ed]            01/01/70 00:00      

Back to Subject List