 page	60,132
; BRK.ASM   3/25/87
; by David Toth, VE3GYQ, Modified by W0RLI
;               modified by JH1NAI (jul.29,1987)
;               modified by JH1RSV (nov.03,1988)
; These are C callable routines, called by
; brkoff()  --	to set ctrl-brk interrupt (1BH) and ctrl-c interrupt (23H)
;		so that it is ignored and execution continues.
; brkon()   --	resets ctrl-brk to its normal action.

_TEXT	SEGMENT BYTE PUBLIC 'CODE'

	assume	cs:_text

	PUBLIC	_brkoff,_brkon

;eswd    dw      ?
;bxwd    dw      ?

_brkoff     proc far

	    push bp
	    mov bp,sp
	    push ds
	    push di
	    push si

;           mov ax,351bh       ; get ctl_brk interrupt vector
;           int 21h            ; vector returned in ES:BX
;           mov cs:bxwd,bx
;           mov cs:eswd,es     ; save the old vector to return later

	    push cs	       ; the data segment
	    pop  ds

;           mov dx,offset do_ti
;           mov ax,251bh       ;  set interrupt vector
;           int 21h            ; ctrl-brk routine is now at do_ti

	    mov dx,offset do_it
	    mov ax,2523h       ; set interrupt vector
	    int 21h	       ; ctrl-c routine is now at do_it

	    pop  si
	    pop  di
	    pop  ds
	    pop  bp

	    ret
_brkoff     endp

; Control-C interrupt handler.

do_it	    proc far
	    clc 	       ;zero the carry flag which
	    ret 	       ;allows program to continue execution
do_it	    endp

; Control-break interrupt handler.

;do_ti       proc far
;           iret               ;allows program to continue execution
;do_ti       endp

_brkon      proc far

;           push bp
;           mov bp,sp
;           push ds
;           push di
;           push si

;           mov ds,cs:eswd     ; put ES word back into DS
;           mov dx,cs:bxwd     ; put BX word back into DX
;           mov ax,251bh       ; set interrupt vector
;           int 21h            ; ctrl-brk is restored

;           pop  si
;           pop  di
;           pop  ds
;           pop  bp
;
            ret
_brkon      endp


; return status of keyboard without allowing CTRL-C to signal break.


_TEXT	ENDS
	    end
