Specifications

Apple II Technical Notes
Apple IIGS
4 of 6 #71: DA Tips and Techniques
When this routine calls RealCDAentry, the carry flag is set if no extra stack space is available.
If the carry is clear, the additional stack space was available and the direct-page register points to
the bottom of that space.
RealCDAentry bcs smallStack ;if c set, only 1 page of stack is
available
... ; put something interesting here
rtl
smallStack _SysBeep
rtl
Note that interrupts are disabled while the page-one stack is being restored; they are reenabled (if
they were originally enabled) only after the stack pointer is safely back in page one.
Interrupts, Event Manager, Memory, and CDAs
Whether the Event Manager is active or not, the user hits Apple-Ctrl-Esc and usually gets to the
CDA menu. It looks the same, but what happens internally is different affects what happens
when your CDA allocates memory.
When the Event Manager is active (as it normally is while the user is running a Desktop
application), hitting Apple-Ctrl-Esc posts a deskAcc event to the event queue. The CDA menu
appears only when the application calls GetNextEvent or EventAvail with the deskAcc
bit enabled in the event mask.
So with the Event Manager active, the CDA menu and individual CDAs are running in the
“foreground”—no processor interrupt is being serviced, and the foreground application is stuck
inside the GetNextEvent or EventAvail call. The Memory Manager knows that no
interrupt is in progress, so it will happily compact and purge memory if necessary to carry out a
memory allocation request from your CDA. This is just fine, since the foreground application
made a toolbox call—unlocked memory blocks are not guaranteed to stay put.
When the Event Manager is not active, hitting Apple-Ctrl-Esc either enters the CDA menu
immediately (if the system Busy Flag is zero) or calls SchAddTask so that the CDA menu
appears during a the next DECBUSYFLG call that brings the system Busy Flag down to zero. If
the CDA menu appears during a DECBUSYFLG , normal memory compaction and purging are
possible, just like when the Event Manager is active.
But if the Busy Flag was zero when the user hit Apple-Ctrl-Esc, then the CDA menu appears
inside of the interrupt, and the foreground application is at an unknown point where it may
justifiably expect that unlocked memory blocks will not move or be purged (see Apple IIGS
Toolbox Reference, Volume 1, page 12-5). (Note that the Desk Manager does a tricky dance to
allow additional interrupts to occur, even though the Apple-Ctrl-Esc interrupt will not return
until the user chooses Quit from the CDA menu. Normally interrupts cannot be nested; the Desk
Manager and AppleTalk are exceptions.)