44
K
A
DAK
Application Tasks
3.11 Exit Procedures
An AMX system can be shut down in an orderly fashion by a task call to procedure
ajexit. The manner in which the operating system ends execution is application
dependent. For example, hardware interfaces may require restoration to their initial
states.
AMX supervises the shutdown process by sequentially calling all of the application Exit
Procedures in the order defined in the Exit Procedure List in your System Configuration
Module (see Chapter 14.6). Once all Exit Procedures have been executed, AMX returns
to the original program that launched AMX with an ajentr call.
When AMX calls an Exit Procedure, the following conditions exist:
Interrupts are enabled.
All registers are free for use.
DS,ES DGROUP segment
SS:SP Task stack which was in effect when ajexit was called.
The direction flag is set to forward.
Exit Procedures are written as Large or Medium model C procedures without formal
parameters.
void cdecl epproc(void) /* Exit Procedure */
{:
Do exit processing
:
}
An Exit Procedure is coded in assembler as a FAR procedure as follows:
USER_CODE SEGMENT BYTE 'CODE'
;ASSUME CS:USER_CODE
;
EPPROC PROC FAR
:
Exit Procedure code goes here.
:
RET
;
EPPROC ENDP
;
USER_CODE ENDS