home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / c / 3198 < prev    next >
Encoding:
Text File  |  1992-12-13  |  1.4 KB  |  49 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!munnari.oz.au!metro!basser.cs.su.oz.au!swift!suite.sw.oz.au!peterc
  3. From: peterc@suite.sw.oz.au (Peter Chubb)
  4. Subject: Assignment operator and volatile
  5. Organization: Softway Pty Ltd
  6. Date: Sun, 13 Dec 92 21:57:52 GMT
  7. Message-ID: <1992Dec13.215752.29143@softway.sw.oz.au>
  8. Sender: news@softway.sw.oz.au (Usenet)
  9. Lines: 38
  10.  
  11.  
  12. In the ISO standard, section 6.3.16, semantics, it states:
  13.     An assignment expression has the value of the left operand
  14.     after the assignment.
  15. My question is, how soon after the assignment?
  16.  
  17. If I write code that looks like this:
  18.  
  19. #define    ap    ((volatile char *)0x1234)
  20.  
  21. ...
  22.     *ap = *ap = 1;
  23.  
  24. (where the char at 0x1234 may be write-only, and return garbage when read,)
  25. should a strictly conforming compiler generate a read instruction
  26. after its write instruction, or can it assume that immediately after
  27. the assignment, the char has the value 1?
  28.  
  29.     I.e., in 68000 code, 
  30.  
  31.     move.l    #$1234,a0
  32.     move.b    #1,d0
  33.     move.b    d0,(a0)
  34.     move.b    (a0),d0    <-- Is this instruction necessary?
  35.     move.b    do,(a0);
  36.  
  37. I would hope that the marked instruction is NOT necessary: if the
  38. phrase `after the assignment' can be interpreted to mean `immediately
  39. after the assignment' it is not; other wise, it is.
  40.  
  41.  
  42.             Regards,
  43.  
  44.                 - Peter Chubb
  45.  
  46. Softway Pty Ltd, P.O. Box 305, Strawberry Hills, NSW 2012, AUSTRALIA
  47. Phone: +61 2 698 2322;       Fax: +61 2 699 9174;     Telex: AA27987
  48. Internet: peterc@softway.oz.au       UUCP: ...!uunet!softway.oz!peterc
  49.