This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17336] AVRGCC ignores "volatile" keyword for "register" variables
- From: "m_klokov at mail dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Sep 2004 16:17:41 -0000
- Subject: [Bug c/17336] AVRGCC ignores "volatile" keyword for "register" variables
- References: <20040906135657.17336.m_klokov@mail.ru>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From m_klokov at mail dot ru 2004-09-27 16:17 -------
(In reply to comment #4)
> Not a bug, volatile on global registers means nothing.
Volatile means volatile...
Let me explain more... There are 32 registers in AVR-core. GCC uses only 16.
So other registers I can use in asm-code. As you know asm-routines are usually
high-speed low-level drivers, interrupt handlers, often with some "tricks"
(like fixed execution time or something like this - something you can't
do with C).
OK. Lets say asm-code is the interrupt handler and it use free register to
notify the main C-program about some event. It uses register because it's much
faster then RAM, and much more comfortable.
So how can i define such register to allow C-code to access it ???
I should use the "register" keyword obviously...
AND I should use the "volatile" keyword to say compiler that value
can be changed by interrupt handler... (not by C-sentence)
and the code MUST reread the value in a manner I wrote in my C-code
(i.e. don't optimize it).
It's THE STANDARD MEANINGS of theese keywords...
You must be assuming that C-compiler must use all the available registers?
Or hardware always has small number of registers?
If so, you make GCC-compiler HARDWARE-DEPENDENT...
My english is not so good, Sorry.
Please ask if you have any questions.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17336