summaryrefslogtreecommitdiff
path: root/reference/C/SYNTAX/volatile.html
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2008-01-27 11:37:44 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2008-01-27 11:37:44 +0100
commit7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch)
treeb1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/SYNTAX/volatile.html
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/SYNTAX/volatile.html')
-rw-r--r--reference/C/SYNTAX/volatile.html97
1 files changed, 97 insertions, 0 deletions
diff --git a/reference/C/SYNTAX/volatile.html b/reference/C/SYNTAX/volatile.html
new file mode 100644
index 0000000..1de9b13
--- /dev/null
+++ b/reference/C/SYNTAX/volatile.html
@@ -0,0 +1,97 @@
+<html>
+<head>
+<title>The VOLATILE keyword.</title>
+<script language="JavaScript">
+</script>
+</head>
+<body bgcolor="#ffffcc">
+<hr>
+<center><h1>The VOLATILE keyword.</h1></center>
+<hr>
+I have had several sugestions on how to describe volatile,
+If you have any input please mail me.
+<ul>
+<li>The <b>volatile</b> <a href="../glossary.html#keyword">keyword</a> acts as a
+<a href="../CONCEPT/data_types.html">data type</a> qualifier.
+The qualifier alters the default why in which
+the compiler handles the variable and does not attempt to optimize the
+storage referenced by it. <i>Martin Leslie</i>
+<p>
+<li><b>volatile</b> means the storage is likely to change at anytime
+and be changed but something outside the control of the user program.
+This means that if you reference the variable,
+the program should always check the physical address (ie a mapped input fifo),
+and not use it in a cashed way.<i>Stephen Hunt</i>
+<p>
+<li>Here is an example for the usage of the volatile keyword:
+<pre>
+ /* Base address of the data input latch */
+
+ volatile unsigned char *baseAddr;
+
+ /* read parts of output latch */
+
+ lsb = *handle-&gt;baseAddr;
+ middle = *handle-&gt;baseAddr;
+ msb = *handle-&gt;baseAddr;
+</pre>
+Between reads the bytes are changed in the latch.
+<p>
+Without the volatile, the compiler optimises this to a single assignment:
+<pre>
+ lsb = middle = msb = *handle-&gt;baseAddr;
+</pre>
+<i>Tim Potter</i>
+<p>
+<li>A <b>volatile</b> variable is for dynamic use. E.G. for data that is to
+be passed to an I/O port Here is an example.
+
+<pre>
+ #define TTYPORT 0x17755U
+
+ volatile char *port17 = (char)*TTYPORT;
+ *port17 = 'o';
+ *port17 = 'N';
+</pre>
+Without the <b>volatile</b> modifier, the compiler would think that the
+statement <code>*port17 = 'o';</code> is redundant and would remove it
+from the object code. The volatile statement prevents the compiler
+optimisation.<i>Alex Arzon</i>.
+</ul>
+
+<hr>
+<h2>Examples:</h2>
+<img src="../../GRAPHICS/computer.gif" align=left alt="o"> No example:-(
+<br clear=left>
+<hr>
+<h2>See also:</h2>
+<ul>
+<li><a href="../CONCEPT/data_types.html#qualifier">const qualifier</a>
+</ul>
+
+
+<p>
+
+<hr>
+<p>
+<center>
+<table border=2 width="80%" bgcolor="ivory">
+<tr align=center>
+<td width="25%">
+<a href="../cref.html"> Top</a>
+</td><td width="25%">
+<a href="../master_index.html"> Master Index</a>
+</td><td width="25%">
+<a href="keywords.html"> Keywords</a>
+</td><td width="25%">
+<a href="../FUNCTIONS/funcref.htm"> Functions</a>
+</td>
+</tr>
+</table>
+</center>
+<p>
+<hr>
+<address>Martin Leslie
+</address><p>
+</body>
+</html>