PAGE 75, 132 TITLE INT8 Demo - Revised 10/97 ; Copyright 1996, 1997, John Lockwood extrn dspmsg:near, binasc:near ; Lib291 Routine ;====== SECTION 4: Define code segment ==================================== stkseg segment stack db 64 dup ('STACK ') stkseg ends ;====== SECTION 4: Define code segment ==================================== cseg segment public 'CODE' assume cs:cseg, ds:cseg, ss:stkseg, es:nothing ;====== SECTION 5: Declare variables for main procedure =================== 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 pbuf DB 7 dup(?) ;====== SECTION 6: Main procedure ========================================= main proc far mov ax, cseg ; Initialize DS=CS mov ds, ax mov ax,0B800h ; Set ES=VideoTextSegment mov es, ax call Install ; Insert my ISR showc: MOV AX,mcount ; Minute Count MOV BX,offset pbuf call binasc mov BX,offset pbuf mov DI,0 ; Column 0 mov AH,00001100b ; Intense Red call pxy MOV AX,scount ; Second Count MOV BX,offset pbuf call binasc mov BX,offset pbuf mov DI,12 ; Column 6 (DI=12/2) mov AH,00001010b ; Intense Green call pxy mov ax,count ; Interrupt Count (1/18th sec) mov bx,offset pbuf call binasc mov BX,offset pbuf mov AH,00000011b ; Cyan mov DI,24 ; Column 12 (DI=24/2) call pxy MOV AH,1 INT 16h ; Key Pressed ? JZ showc Call DeInst ; Restore original INT8 MOV AX,4c00h ; Normal DOS Exit int 21h ret main endp pxy proc near ; Undocumented code push es ; (Not relevant to interrupts) push bx pxyl: mov al,[bx] cmp AL,'$' JE pxydone mov es:[di],AX inc BX Add DI,2 JMP pxyl pxydone:pop bx pop es ret pxy endp Install proc near ; Install new INT 8 vector PUSH ES MOV AL,8 ; INT = 8 MOV AH,35h ; Subfunction = 35h (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 = 25h (Set Vector) MOV DX,offset myint ; DS:DX point to function INT 21h ; DOS Service POP ES RET Install ENDP DeInst proc near ; Deinstall Routine (Reinstall old vector) PUSH DS MOV DX,word ptr Oldv+0 MOV DS,word ptr Oldv+2 MOV AL,8 ; INT = 8 MOV AH,25h ; Subfunction = 25h (Set Vector) INT 21h ; DOS Service POP DS RET DeInst endp myint proc near push DS ; Save all registers push AX MOV AX,CS ; Load default segment MOV DS,AX pushf ; Call Orig Function (it will IRET and pop 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 cseg ends end main