This is the past DOS era of the compilation of source code, although has passed, but for the study of the assembly is still helpful, assembly language is just a basic programmer language, most people can grasp, not necessarily in-depth research.
;
; Serial communications port Interupt Intercepter AHA 8502.27
;
; Functions:
; Al=0 then Disable communications interupt Vector
; Al=1 then Enable communications interupt Vector
; Issue and int 44h
;
PROGSEG segment para public ' CODE '
Public setcom
Assume Cs:progseg, ds:progseg, es:progseg
Org 100h
Doscall equ 21h
;
startup proc Far
JMP Setup
;
setcom proc Far
Push DS
Push ES
Push DX
Push AX
MOV Ax,cs
MOV Ds,ax
MOV Es,ax
Pop ax
CMP al,1. is function 1
JZ enable; then enable
;
Disable
mov dx,offset interupt; get new vector address
MOV Ax,cs
mov ds,ax; set segment
mov ah,25h set interupt vector address function
MOV al,14h; communications interupt Vector
int doscall; Set the Interupt
JMP Exit exit
Enable
mov dx,word ptr vector; set old segment
MOV ds,vector+2; set old communications vector
mov ah,25h set interupt vector address function
MOV al,14h; communications interupt Vector
int Doscall
Exit
Pop DX
Pop es
Pop ds
;
interupt proc Far
Sub Ax,ax; zero return status
Iret
Interupt ENDP
setcom ENDP
;
MSG DB ' serial communications Intercepter installed ', 0AH,0DH, ' $ '
MSG1 DB ' serial communications Intercepter is already installed ', 0AH,0DH, ' $ '
Vector DB 8 dup (0); only 4 needed 4 safety
;
Setup
mov ah,35h to interupt vector address function
MOV al,44h; communications interupt Vector
int doscall; go get it
CMP bx,0 check if vector used
JNZ lderr if used then exit
mov ax,es; check segment
CMP ax,0
JNZ Lderr
;
MOV dx,offset msg
MOV ah,9
int Doscall
;
mov ah,35h to interupt vector address function
MOV al,14h; communications interupt Vector
int doscall; go get it
;
mov word ptr vector,bx; save offset
mov bx,es; get segment Address
mov word ptr vector+2,bx; save segment
;
mov dx,offset setcom; get new vector address
MOV Ax,cs
mov ds,ax; set segment
mov ah,25h set interupt vector address function
MOV al,44h set to our new interupt vector
int doscall; Set the Interupt
;
MOV dx,offset setup; terminate and stay resident
int 27h
Lderr:
MOV dx,offset MSG1
MOV ah,9
int Doscall
int 20h
Startup ENDP
Progseg ends
;
End Startup