| ??? 01/23/03 14:43 Read: times |
#36996 - RE: volatile keyword |
Yes I believe so Andy. However in any case if there is ever a question you can always make the code, compile it and then look either at the resulting machine language in the debugger or at the intermediate assembly language source code. (Keil for instance has the #pragma SRC(filename.a51) which you can put at the very top of a C source file to get the compiler to make an assembler source for the module you are compiling.
One use I have had for a volatile type variable in past project was in the following type context. If you are defining a memory mapped peripheral that is placed at a particular address in XDATA it will be well to declare the symbol for the port address as a volatile variable. If you needed to simply toggle a bit in this port to make someting happen in the peripheral (such as increment an address register) then code may look like.... xdata volatile unsigned char ctl_reg _at_ 0x8000; . . . . . . ctl_reg = 0x80; /* toggle bit 7 on */ ctl_reg = 0x00; /* toggle bit 7 off */ . . . Here the volatile attribute applied to the ctl_reg variable will assure you that compiler will generate both of the writes to the variable "ctl_reg" and the optimizer should not try to take away the first actual write. Michael Karas |
| Topic | Author | Date |
| volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
| RE: volatile keyword | 01/01/70 00:00 | |
volatile keyword and not-so-optimizer | 01/01/70 00:00 |



