home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3201 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  1.5 KB

  1. Path: sparky!uunet!think.com!ames!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  2. From: torek@horse.ee.lbl.gov (Chris Torek)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Assignment operator and volatile
  5. Date: 14 Dec 1992 02:16:35 GMT
  6. Organization: Lawrence Berkeley Laboratory, Berkeley CA
  7. Lines: 36
  8. Message-ID: <27964@dog.ee.lbl.gov>
  9. References: <1992Dec13.215752.29143@softway.sw.oz.au>
  10. NNTP-Posting-Host: 128.3.112.15
  11.  
  12. In article <1992Dec13.215752.29143@softway.sw.oz.au>
  13. peterc@suite.sw.oz.au (Peter Chubb) writes:
  14. >#define    ap    ((volatile char *)0x1234)
  15. >    *ap = *ap = 1;
  16.  
  17. (Side issue: I would be much happier with this if it were, e.g.,
  18.  
  19.     char v;
  20.     v = *ap = 1;
  21.  
  22. so that there are not two independent writes to *ap without an
  23. intervening sequence point.  Ignoring that issue:)
  24.  
  25. >(where the char at 0x1234 may be write-only, and return garbage when read,)
  26. >should a strictly conforming compiler generate a read instruction
  27. >after its write instruction, or can it assume that immediately after
  28. >the assignment, the char has the value 1?
  29.  
  30. My own interpretation is that the compiler can do as it pleases, but
  31. must document what it does.
  32.  
  33. >    I.e., in 68000 code, 
  34. >
  35. >    move.l    #$1234,a0
  36. >    move.b    #1,d0
  37. >    move.b    d0,(a0)
  38. >    move.b    (a0),d0    <-- Is this instruction necessary?
  39. >    move.b    d0,(a0)
  40.  
  41. I believe this would be a valid translation both with and without
  42. the marked line, given appropriate compiler documentation.
  43.  
  44. (Incidentally, GCC apparently uses the `re-read' interpretation.)
  45. -- 
  46. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  47. Berkeley, CA        Domain:    torek@ee.lbl.gov
  48.