;[]-------------------------------------------------------------------------[]
;|	Program name: A_3.ASM                                                |
;|	Image   file: A_3.COM                                                |
;|	Note        : This is not a TSR program.                             |
;|		      This program is used to show the TRAP interrupt.       |
;[]-------------------------------------------------------------------------[]


cseg	segment
	assume	cs:cseg,ds:cseg
	org	100H
start:
	jmp	initialize

;------- Data area ---------------------

old_int01	dd	?
old_int61	dd	?

;------- Include area ------------------

DEBUG		EQU	1
include	register.inc
include	interrup.inc
include	debug.inc

;------- Interrupt subroutine ----------

new_int01	proc	far

	push	bp
	mov	bp,sp
	mov	dx,[bp+6]		; Let DX hold the old flag value
	pop	bp

	jmp	near ptr new_int61

new_int01	endp

;------- Initial procedure -------------

initialize:

	assume	cs:cseg,ds:cseg

	get_int	01H,old_int01
	set_int	01H,<offset new_int01>
	get_int	61H,old_int61
	set_int	61H,<offset new_int61>

	mov	ax,0			; Let AX initial value be 0
	pushf				; Let the old flag keep in stack

	pushf				; This routine is used to set T flag
	pop	bx			; and the following routine will cause
	or	bx,100H			; interrupt 01H
	push	bx			;
	popf				;

	mov	ax,1			; When this instruction is done, it will
	mov	ax,2			; generate interrupt 01H
	mov	ax,3
	mov	ax,4
	popf				; Restore the old flag value
next:
	assume	cs:cseg,ds:nothing

	set_int	01H,<word ptr old_int01>,<word ptr old_int01[2]>
	set_int	61H,<word ptr old_int61>,<word ptr old_int61[2]>

	mov	ah,4CH
	int	21H

cseg	ends
	end	start
