Assembly Source series of Comint

Source: Internet
Author: User
Tags exit

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.