Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!fernwood!portal!atari!apratt From: apratt@atari.UUCP (Allan Pratt) Newsgroups: comp.sys.atari.st Subject: Re: The cause of the phantom typist Message-ID: <2893@atari.UUCP> Date: 4 Apr 91 21:13:42 GMT References: <3865050@janhh.hanse.de> <1991Apr3.184636.7591@imada.dk> Organization: Atari Corp., Sunnyvale CA Lines: 28 micro@imada.dk (Klaus Pedersen) writes: >> To exorcise one may >> 1) Replace expressions like ++i; if(i == ANYPOWEROFTWO) i= 0; >> by ++i &= (ANYPOWEROFTWO - 1) >jan@janhh.hanse.de (Jan Willamowius) writes: > in what language do you want to write that? >What you are writing is : > ++i = ++i & (APO2-1); > - no matter how you try to hide it... That's not true. Semantically, "i += 2;" is equivalent to "i = i + 2;" but "++i += 2;" is not equivalent to "++i = ++i + 2;" because the people who designed C are smarter than that. The side-effect is performed only once. But regardless of that, you are suggesting that what happens in a C statement is uninterruptable, so doing something in a single statement makes it safe when it might be unsafe in multiple statements. This is not true. On the 68000 family, an interrupt can come between any two instructions. Individual instructions can't be interrupted, but the bus can be arbitrated away (for DMA, for example) between the read and the write of a read-modify-write instruction, except for the TAS instruction which is explicitly atomic. ============================================ Opinions expressed above do not necessarily -- Allan Pratt, Atari Corp. reflect those of Atari Corp. or anyone else. ...ames!atari!apratt