; INT8 Demo - Revised 10/97 ; Copyright 1996, 1997, John Lockwood ;====== Variables =================== oldv DD ? ; Old Vector (far pointer to old interrupt function) count DW 0 ; Interrupt counter (1/18th second) scount DW 0 ; Second counter mcount DW 0 ; Minute counter ;====== Main procedure ========================================= main proc far .. ; ---- Install Interrupt Routine----- call Install ; ---- Main Body of Program (print count values) ----- showc: MOV AX,mcount ; Minute Count .. call pxy MOV AX,scount ; Second Count .. call pxy mov ax,count ; Interrupt Count (1/18th sec) .. call pxy MOV AH,1 INT 16h ; Check for key press JZ showc ; (Quit on any key) ; ---- Deinstall Interrupt Routine----- Call DeInst ; Restore original INT8 .. main endp ;====== Helper Function ========================================= pxy proc near ; Prints Text on Screen .. pxy endp ;====== Install Interrupt ========================================= Install proc near ; Install new INT 8 vector PUSH ES MOV AL,8 ; INT = 8 MOV AH,35h ; Subfunction = Read Vector INT 21h ; DOS Service MOV WORD PTR Oldv+0,BX MOV WORD PTR Oldv+2,ES MOV AL,8 ; INT = 8 MOV AH,25h ; Subfunction = Set Vector MOV DX,offset myint ; DS:DX point to function INT 21h ; DOS Service POP ES RET Install ENDP ;====== Deinstall Interrupt ========================================= DeInst proc near ; Deinstall Routine ; (Reinstall old vector) .. MOV DX,word ptr Oldv+0 MOV DS,word ptr Oldv+2 MOV AL,8 ; INT = 8 MOV AH,25h ; Subfunction = Set Vector INT 21h ; DOS Service .. RET DeInst endp ;====== ISR Code =============================================== myint proc near push DS ; Save all registers push AX MOV AX,CS ; Load default segment MOV DS,AX pushf ; Call Orig Function w/flags call oldv ; Far Call to existing routine INC count ; Increment Interupt count CMP count,18 JNE myintd INC scount ; Next second MOV count,0 CMP scount,60 JNE myintd INC mcount ; Next minute MOV scount,0 myintd: POP AX ; Restore all Registers POP DS IRET ; Return from Interrupt myint endp ;===============================================================