🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3013

Assignment operator and volatile

#3013
From: Peter Chubb
Date: Sun, 13 Dec 1992 21:57
38 lines
1521 bytes
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
Technical Details
Message-ID: <1992Dec13.215752.29143@softway.sw.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!basser.cs.su.oz.au!swift!suite.sw.oz.au!peterc

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!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