[comp.sys.apple] Interrupt enabling

mattd@Apple.COM (Matt Deatherage) (04/04/89)

After more digging and thinking, and consultation with some folks who are
Knowledgeable about such things, I retract the previous statement that
applications should not use CLI, but I stick by its taboo for low-level
routines.

The problem with assuming that interrupts are enabled if they can be when
your application gets control is pretty basic:  it's simply not true.  On 8-bit
machines, the I flag is randomly set or cleared depending on the state of the
flag when someone loaded the program.  (For example, if you boot into it, I
is usually set [interrupts disabled], but if you launch it long after a boot,
interrupts are generally enabled.)  On the IIgs, interrupts are generally
enabled except in special cases, as the ROM goes to certain pains to make sure
this is true.

But still, at a low level, arbitrarily enabling interrupts could be a bad
thing.  It could mess up the timing of someone that called your routine
(especially if your routine is in firmware) with interrupts disabled.  So in
general, CLI should be avoided except by an application, which should do it
once at the beginning if so desired.  Any later disabling of interrupts should
be done with the PHP/SEI sequence, and restored with PLP.  This method assures
interrupts are enabled everywhere it is safe for them to be enabled.

-----------------------------------------------------------------------------
Matt Deatherage, Apple Computer, Inc. | "The opinions expressed in this tome
Send PERSONAL mail ONLY (please) to:  | should not be construed to imply that
AppleLink PE: Matt DTS  GEnie: AIIDTS | Apple Computer, Inc., or any of its
CompuServe: 76703,3030                | subsidiaries, in whole or in part,
Usenet:  mattd@apple.com              | have any opinion on any subject."
UUCP:  (other stuff)!ames!apple!mattd | "So there."
-----------------------------------------------------------------------------