[net.micro.68k] Warning: Don't use the 'clr' instruction on device registers

ggr (03/10/83)

There is a peculiarity of the 68000 you should be aware of,
particularly when accessing device registers (such as those on the
Intel 8274 USART) which are fussy about whether they are being read
or written.  We had been trying to write a zero in a particular
device register and had discovered the reason the device wasn't
acting as it should is that the 68000 was reading the location
before writing it.  We had coded a statement like
	dev->register = 0;
in C, and the C compiler had generated a 'clr' instruction.
Sounds reasonable so far.  But checking the manual, there is a Note
that states the memory location is read before written [I compliment
Motorola for not hiding (too deeply) this fact].

The compiler could be changed not to generate 'clr's, but that would
penalize the far more frequent accesses to "normal" memory.
So the moral is be careful about how you access device registers.

				=== Guy Riddle == BTL Piscataway ===
(P.S. One solution is 
	dev->register = zero;
You can guess what is in 'zero'.)