home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!munnari.oz.au!metro!basser.cs.su.oz.au!swift!suite.sw.oz.au!peterc
- From: peterc@suite.sw.oz.au (Peter Chubb)
- Subject: Assignment operator and volatile
- Organization: Softway Pty Ltd
- Date: Sun, 13 Dec 92 21:57:52 GMT
- Message-ID: <1992Dec13.215752.29143@softway.sw.oz.au>
- Sender: news@softway.sw.oz.au (Usenet)
- Lines: 38
-
-
- In the ISO standard, section 6.3.16, semantics, it states:
- An assignment expression has the value of the left operand
- after the assignment.
- My question is, how soon after the assignment?
-
- If I write code that looks like this:
-
- #define ap ((volatile char *)0x1234)
-
- ...
- *ap = *ap = 1;
-
- (where the char at 0x1234 may be write-only, and return garbage when read,)
- should a strictly conforming compiler generate a read instruction
- after its write instruction, or can it assume that immediately after
- the assignment, the char has the value 1?
-
- I.e., in 68000 code,
-
- move.l #$1234,a0
- move.b #1,d0
- move.b d0,(a0)
- move.b (a0),d0 <-- Is this instruction necessary?
- move.b do,(a0);
-
- I would hope that the marked instruction is NOT necessary: if the
- phrase `after the assignment' can be interpreted to mean `immediately
- after the assignment' it is not; other wise, it is.
-
-
- Regards,
-
- - Peter Chubb
-
- Softway Pty Ltd, P.O. Box 305, Strawberry Hills, NSW 2012, AUSTRALIA
- Phone: +61 2 698 2322; Fax: +61 2 699 9174; Telex: AA27987
- Internet: peterc@softway.oz.au UUCP: ...!uunet!softway.oz!peterc
-