home *** CD-ROM | disk | FTP | other *** search
- PAGE 66,132
-
- ; Program SSTACK - Set up larger stack for Interrupt Routine
- ; by Stephen R. Davis, 1987
- ;
- ; Because of the extreme stack demands of Turbo C, it is necessary
- ; to set up a larger stack before entering interrupt routines written
- ; in Turbo C with some versions of DOS. In particular, Programs 9_2b
- ; and c work fine with DOS 3.0 but require SSTACK with 3.1. SSTACK
- ; should only be executed as a .COM program.
- ;
-
- VECT EQU 68H ;SET TO UNUSED INTERRUPT
-
- CSEG SEGMENT
- ASSUME CS:CSEG,DS:CSEG,SS:CSEG
- ORG 100H ;MAKE THIS INTO A .COM FILE
-
- START:
- JMP INSTALL
-
- ORG 200H
- SAVESP DW 0 ;ALLOCATE PLACE TO STORE OLD SS:SP
- SAVESS DW 0
- SFLAG DW 0
-
- INTRUPT:
- CMP CS:SFLAG,0 ;IS FLAG CLEAR?
- JZ NEWSTACK
- INT 68H
- IRET
- NEWSTACK:
- MOV CS:SFLAG,1
- MOV CS:SAVESP,SP ;SAVE CALLER'S STACK
- MOV CS:SAVESS,SS
- MOV SP,CS ;PUT IN OUR OWN
- MOV SS,SP
- MOV SP,200H
-
- INT VECT ;NOW INVOKE CLOCK INTERRUPT
-
- MOV SS,CS:SAVESS ;NOW RESTORE CALLER'S STACK
- MOV SP,CS:SAVESP
- MOV CS:SFLAG,0
- IRET
- ENDINT:
-
- MESSG DB "Clock interrupt stack helper installed",0DH,0AH,"$"
- NOTUSMSG DB "Interrupt already in use -- try another",0DH,0AH,"$"
- USMSG DB "Do not install SSTACK more than once",0DH,0AH,"$"
-
- ASSUME CS:CSEG,DS:CSEG,SS:CSEG
- INSTALL:
- MOV AX,3500H+VECT ;CHECK THE TARGET VECTOR
- INT 21H
- OR BX,BX ;IN USE?
- JNZ ERR
- ;NO - GO AHEAD THEN
- MOV AX,3508H ;GET TIMER VECTOR
- INT 21H
- MOV DX,BX ;INSTALL TIMER INTO 'VECT'
- MOV AX,ES
- PUSH DS
- MOV DS,AX
- MOV AX,2500H+VECT
- INT 21H
- POP DS
-
- MOV DX,OFFSET INTRUPT ;INSTALL OURSELVES IN CLOCK INT
- MOV AX,2508H
- INT 21H
-
- MOV DX,OFFSET MESSG ;SEND ALL'S WELL MESSAGE
- MOV AH,09H
- INT 21H
-
- MOV AX,3100H ;KEEP PROCESS WITH 0 ERROR CODE
- MOV DX,OFFSET ENDINT
- MOV CL,4 ;CONVERT BYTES TO PARAGRAPHS
- SHR DX,CL
- INC DX ;ACCOUNT FOR ROUND OFF
- INT 21H
-
-
- ERR:
- MOV AX,3508H ;GET THE TIMER INTERRUPT
- INT 21H
-
- CMP BX,OFFSET INTRUPT ;IT IS US?
- MOV DX,OFFSET NOTUSMSG ;ASSUME IT ISN'T
- JNZ NOTUS
- MOV DX,OFFSET USMSG ;IT IS US
- NOTUS:
- MOV AH,09H
- INT 21H
-
- MOV AX,4CFFH ;TERMINATE WITH FF ERROR CODE
- INT 21H
-
- CSEG ENDS
- END START