koreth@ssyx.ucsc.edu (Steven Grimm) (06/14/88)
Submitted-by: uunet!mcvax!philmds!leo (Leo de Wit) Posting-number: Volume 1, Issue 54 Archive-name: errorchk Here is another small memory-resident program to be placed in the AUTO folder. Did you also had times you wanted to see a program's final (error?) message when it flashed over your screen and the desktop was painted all over it. This little program checks whenever a program exits if the caller was the desktop (it does this by following the links in the basepages); if so, a message is printed and you can press a key to continue. The program sets the GEM program exit vector that is at address 0x408; this vector usually points to a RTS statement (i.e. does nothing). After a keypress a jump is made to the old vector (in case it WAS used). This program also prevents the need of coding similar messages into every program that can be called from the desktop. It was assembled using the assembler and linker that come with the GST-C compiler, resulting in a program length of 240 bytes. My name and address: L.J.M. de Wit Nachtegaallaan 7 5731XP Mierlo Holland. --------------- H E R E I T A L L S T A R T S ------------------------- MODULE DTOPWAIT SECTION S.CCODE GEMDOS EQU 1 BIOS EQU 13 PTERMRES EQU $31 SETEXC EQU 5 ESC EQU $1B DTWINIT MOVE.L #-1,-(SP) MOVE.W #$102,-(SP) MOVE.W #SETEXC,-(SP) TRAP #BIOS * Save old GEM exit vector ADDQ.L #8,SP LEA.L OLDVEC(PC),A0 MOVE.L D0,(A0) PEA DTOPWAIT MOVE.W #$102,-(SP) MOVE.W #SETEXC,-(SP) TRAP #BIOS * Set new GEM exit vector ADDQ.L #8,SP MOVE.L 4(SP),A0 MOVE.L #$100,D0 * Base page ADD.L 12(A0),D0 * + text length ADD.L 20(A0),D0 * + data length ADD.L 28(A0),D0 * + bss length CLR.W -(SP) * Return value: 0 for success MOVE.L D0,-(SP) * # bytes to keep MOVE.W #PTERMRES,-(SP) * Keep process TRAP #GEMDOS * Stops here... DTOPWAIT MOVE.L $602C,A0 MOVEQ.L #0,D1 BRA.S DTOPAREND DTOPARNT ADDQ.L #1,D1 MOVE.L 36(A0),A0 DTOPAREND TST.L (A0) BNE.S DTOPARNT CMP.B #3,D1 BNE.S DTWEND LEA WAITMSG(PC),A4 BRA.S DTOPW3 DTOPW2 EXT.W D0 MOVE.W D0,-(SP) MOVE.W #2,-(SP) MOVE.W #3,-(SP) TRAP #BIOS ADDQ.L #6,SP DTOPW3 MOVE.B (A4)+,D0 BNE.S DTOPW2 MOVE.W #2,-(SP) MOVE.W #2,-(SP) TRAP #BIOS ADDQ.L #4,SP DTWEND MOVE.L OLDVEC(PC),-(SP) RTS SECTION S.DATA OLDVEC DC.L 0 WAITMSG DC.B 13,10,ESC,'K',ESC,'p',9,9 DC.B 'Program finished; hit a key to return to desktop',ESC,'q',0 END