Grant Edwards wrote:    ...
I'd like to point out that 

1) I didn't write that code originally, I ran across that
example in a thread in the yahoo msp430 list.

2) The example isn't supposed to do anything useful, it's just
a simple test-case that demonstrates a bug in the compiler. 
...
  I didn't write that either.
   
  P1IN is a hardware read-only 8-bit Special Function Register (SFR). Every 
time you read it, it gives a potentially different result. In addition, it may 
result in some side effect in the hardware.
   
  Suppose I want to read P1IN twice and I do not care about the reading and 
only want to cause the hardware side effect twice. In Assembly, I would write:
   mov.b &P1IN,Rx
   mov.b &P1IN,Rx
  where Rx is one of the un-used registers R4-R15.
   
  How do I do the same thing in C?
  (P1IN is declared to be a volatile unsigned char in the header file.)
  Can I write “two =  P1IN + P1N;”?
  How about “if (P1IN + P1IN) {/* nothing */}”?
   
  I am just starting to use c as a tool to generate code for embedded system. I 
understand and accept the fact that in order to be able to use any tool, you 
have to learn how to use that tool first. But is this like priesthood? Do I 
have to recite in Latin?
   
   

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to