1 ; ******************************************** 2 ; * * 3 ; * Copyright, (C) Honeywell Bull Inc., 1988 * 4 ; * * 5 ; ******************************************** 6 ; 7 ; HISTORY COMMENTS: 8 ; 1) change(88-01-23,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel): 9 ; Created. 10 ; END HISTORY COMMENTS 11 ; 12 ;****************************************************************************** 13 ; 14 ; Module: CTRLBRK.ASM 15 ; 16 ; Function: These are a set of routines which are used to manipulate the 17 ; keyboard break handler interrupt in order that the 18 ; <CONTROL><BREAK> key may be handled by setting a flag 19 ; called "break_flag" other than being handled by the default 20 ; handler. 21 ; 22 ; The routine "ctrlbrk" is the handler. What MUST be remembered 23 ; is that this is an interrupt routine and MUST save and restore 24 ; all registers. 25 ; 26 ; Date: January 23, 1988 27 ; 28 ; Author: Michael S. Flegel 29 ; 908-1540-29 Street N.W. 30 ; Calgary, Alberta 31 ; Canada 32 ; T2N-4M1 33 ; (403) 289-3426 34 ; 35 ; Resources: Advanced Computing Technology Centre 36 ; 301-1620-29 Street N.W. 37 ; Calgary, Alberta 38 ; Canada 39 ; T2N-4L7 40 ; (403) 284-6400 41 ; 42 ; Equipment: IBM-PC AT 43 ; IBM-PC DOS 3.10 44 ; Microsoft (R) Overlay Linker, Version 3.51 45 ; IBM Macro Assembler, Version 2.00 46 ; 47 ;****************************************************************************** 48 ^L 49 50 include dos.mac 51 52 BREAK_PENDING = 800h 53 54 ;****************************************************************************** 55 ; DATA SEGMENT 56 ;****************************************************************************** 57 58 dseg 59 60 old_break_cs dw (?) ; old CS of keyboard break routine 61 old_break_ip dw (?) ; old IP of keyboard break routine 62 63 extrn break_flag:word ; term's control flags 64 65 endds 66 67 ;****************************************************************************** 68 ; PROGRAM SEGMENT 69 ;****************************************************************************** 70 71 pseg 72 73 public ctrlbrk 74 public set_break 75 public reset_break 76 77 data_segment dw (?) ; term's data segment register 78 79 ;^L 80 ;****************************************************************************** 81 ; This routine is activated whenever the <CTL><BREAK> keys are simultaneously 82 ; struck. 83 ; 84 ; All that happens is that the global flag "break_flag" is set. 85 ;****************************************************************************** 86 87 ctrlbrk proc near 88 89 push DS ; save used registers 90 pushf 91 92 push CS:data_segment ; set up data addressability 93 pop DS 94 95 or break_flag,BREAK_PENDING ; set the break flag 96 97 popf ; restore used registers 98 pop DS 99 100 iret ; return from interrupt 101 102 ctrlbrk endp 103 ;^L 104 ;****************************************************************************** 105 ; This procedure sets the interrupt 1b routine (keyboard break address) 106 ; to transfer to our "ctrlbrk" routine so that we can handle it ourselves 107 ;****************************************************************************** 108 109 set_break proc near 110 111 push ax ; save registers 112 push bx 113 push dx 114 push ds 115 push es 116 117 ; save the current DS for use by the handler 118 119 push ds 120 pop ax 121 mov CS:data_segment,ax 122 123 ; save the control-break vector (1Bh) 124 125 mov ah,35h ; get the old vector 126 mov al,1bh 127 int 21h 128 129 mov old_break_cs,es ; save the old CS and IP 130 mov old_break_ip,bx 131 132 ; set the new control-break vector 133 134 mov dx,offset ctrlbrk ; set to our ctrlbrk routine 135 push cs 136 pop ds 137 138 mov ah,25h ; signal interrupt to set new vector 139 mov al,1bh 140 int 21h 141 142 pop es ; restore registers 143 pop ds 144 pop dx 145 pop bx 146 pop ax 147 ret 148 149 set_break endp 150 ;^L 151 ;****************************************************************************** 152 ; This routine restores the old interrupt 1b (keyboard break address) routine 153 ; to the one which existed before set_break was invoked. 154 ;****************************************************************************** 155 156 reset_break proc near 157 158 push ax ; save registers 159 push dx 160 push ds 161 162 ; restore saved control-break vector 163 164 mov dx,old_break_ip ; restore the old CTL-BRK vector 165 push old_break_cs 166 pop ds 167 168 mov ah,25h ; signal the interrupt to restore vector 169 mov al,1bh 170 int 21h 171 172 pop ds ; restore registers 173 pop dx 174 pop ax 175 ret 176 177 reset_break endp 178 179 endps 180 end