STXIT


STXIT is a macro instruction for the DOS/360 operating system for the IBM System/360 series of mainframe computers, and its successors on later mainframe series, and was also available for the UNIVAC Series 90 mainframes running its TOS/DOS operating system and later on its VS/9 operating system.

Background

The macro was an abbreviation of the term "Set Exit," and was used by programs written in assembly language. It is used to create a recovery routine in the event of program errors, similar to signal handlers in C and Try/Finally blocks in C++, Java and other object oriented languages.
The STXIT macro would provide an error recovery address for several major types of errors and certain operator signals. The errors covered depended upon the operating system. In general, the errors which it provided recovery included
The timer interrupt STXIT provided a mechanism for sampling program execution and was used by various legacy performance analyzers. Essentially a PSW was gathered for each time interval and used for later analysis to determine hot spots.
The program check STXIT provided a mechanism for program animation via the deliberate introduction of invalid opcodes to locations in the target programs. Once the exit recovery was entered, the original opcode would be restored ready for later resumption and a new location set.

Macro format

The format of the macro call depended upon the system it was used upon.

IBM DOS/VSE

For DOS/VSE it was one of two forms, either the macro call to establish a STXIT routine to handle the appropriate event, or a macro call to de-establish the event. To establish a STXIT routine, you would code:
STXIT, RoutineAddress, SaveArea comment
Where
To de-establish, or cancel a STXIT routine, you would code:
label STXIT comment
to cancel the routine for that event. Everything beginning one space after the parameter is a comment.

IBM z/VSE

For z/System VSE, all STXIT functions provided previously by IBM DOS/VSE are still supported. In addition, a new STXIT macro function 'Disabled Timer Appendage ' is available, but only for use in Supervisor Mode. Format is:
label STXIT DIE,rtnaddr|
Where DIE means the routine is to handle a "Disabled Interval timer Event", and rtnaddr is the address to handle the expiration of an interval timer when a Set TOD event is coded. The address may instead be specified as , meaning the address is stored in register 1. The routine is subject to strict restrictions including not changing any register contents or using most SVCs.

Univac VS/9

For Univac VS/9 it was
STXIT R,,[shutdown comment
Where
As the STXIT macro on VS/9 was parameter based, missing entries had to be entered with commas, e.g. if only the third item was being handled, the format would be
STXIT R,,,RTN1
To remove one or more handlers, the STXIT macro is re-invoked with a blank entry for the handlers to be removed. Only one STXIT macro call can be in effect at any time.
If a class of event is not being handled, it is omitted, and there would be two commas in a row to indicate this. An unhandled class of event causes that error to be handled by the operating system's "default" handler. For events representing critical errors, the program is terminated with an EO79 error and the user has the option to request a PDUMP; for non-critical events the event is ignored.

Later developments

Later error recovery systems would provide for specifying errors explicitly as opposed to by the position of the parameter on the STXIT macro.
Univac's VS/9 continued to support STXIT but also added the CRTN macro to provide even more powerful error recovery, as well as recovery of some errors which STXIT did not capture. Originally, CRTN and STXIT could not be used together. Later releases of the operating system provided for both; if a CRTN and a STXIT macro were both used, the CRTN handled any events not covered by STXIT; if both were used to cover an event, the STXIT routine handled the event and the CRTN routine was not invoked.