⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 中断复制.asm

📁 实现中断复制功能. 除非输入i(I),否则会在屏幕上显出输入的字母或字符值. 以end结束. 具体解释见源程序.
💻 ASM
字号:
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;
 ;张言国
 ;051221140
 ;南京大学05级
 ;主题:实现自定义的中断服务程序,输出字符串“This is an interruption!”。
 ;使用说明:当用户输入非'I' or 'i'字符时,主程序将用户输入的字符重新在屏幕输出,输入 'I' or 'i' 字符时,执行中断服务程序,输出一个字符串。
 


 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;








DATAS SEGMENT
	show1 DB  'runing-----',13,10,'$'
	show2 DB  'input a char,and if it is  I (i) ,interruption program will be run,else it will return what you have input------',13,10,'$'
    msg   DB  ' ---------------This is an interruption!-----------------',13,10,'$' 
    show3 DB  'what you have input is:',13,10,'$' 
    show4 DB  'input E (e) to end,else go on...',13,10,'$'
    show5 DB  'go on...',13,10,'$'
DATAS ENDS

STACKS SEGMENT
    
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;主程序
 ;当用户输入非'I' or 'i'字符时,主程序将用户输入的字符重新在屏幕输出
 ;输入 'I' or 'i' 字符时,执行中断服务程序,输出一个字符串  
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
    main proc far
        
        mov dx,offset show1                       ;输出提示语
        mov ah,09h
        int 21h
        mov dx,offset show2
        mov ah,09h
        int 21h
       
        
        
        mov al,100d                               ;保存原来的100#中断变量
        mov ah,35h
        int 21h
        push es
        push bx
        push ds
    
    
    
        mov dx,offset interrupt                   ;设置新的中断变量
        mov ax,seg interrupt
        mov ds,ax
        mov al,100d
        mov ah,25h
        int 21h
        
     
        pop ds                                    ;恢复当前数据段寄存器的值
        sti                                       ;开中断
        
    L1: mov ah,1                                  ;要求用户输入一个字符若是I i则调用中断服务程序,否则回显字符
        int 21h
        cmp al,'I'
        jz L2
        cmp al,'i'
        jz L2
        
        push ax
        
        call crlf
        
        mov dx,offset show3
        mov ah,09h
        int 21h
        
        pop ax
        mov dl,al
        mov ah,2
        int 21h                                   ;回显字符
        
        call crlf
        
        jmp L1
        
    L2: int 100d
        
        mov dx,offset show4
        mov ah,09h
        int 21h
        
        
        mov ah,1                                  ;用户输入E e则结束程序,否则restart。
        int 21h
        cmp al,'E'
        jz exit
        cmp al,'e'
        jz exit
        call crlf
        
        mov dx,offset show5
        mov ah,09h
        int 21h
        
        jmp L1
        
        
 exit:  pop dx                                    ;恢复原来100#中断向量
        pop ds
        mov al,100d
        mov ah,25h
        int 21h
        
        
        
        MOV AH,4CH                                ;结束程序
        INT 21H    
        
 
    main endp
 
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
 ;中断服务程序,输出一行字符串 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    interrupt  proc near                                         
        push ds                                 ;保护寄存器现场
        push ax
        push cx
        push dx
        
        mov ax,datas
        mov ds,ax
        sti
        
        call crlf
        call crlf
        mov dx,offset msg                       ;输出字符串
        mov ah,09h
        int 21h
        call crlf
        call crlf
        cli
        
        pop dx                                  ;恢复寄存器现场
        pop cx
        pop ax
        pop ds
        
        
        
        iret
     interrupt endp
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      
 ;辅助过程 
 ;实现回车以及换行
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      
  crlf    proc  near  
                       
        mov dl,0dh               
        mov ah,2                  
        int   21h                 
        mov dl,0ah                
        mov ah,2                 
        int   21h  
        
        ret                      
  crlf    endp   
    
        
    
    

CODES ENDS
    END START












⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -