• 汇编语言中断编程步骤


    一、编写中断程序

    1、调用movsb指令将中断处理程序载入内存的指定位置;
    1)使用offset指令计算doIntEnd-doInt获取中断处理程序的代码长度;
    2)doIntEnd位置使用nop指令。
    2、修改中断向量表项为指定位置;
    1)使用word ptr确定内存单元;
    2)使用es=0来定位中断向量表首地址。
    3、编写中断处理程序。
    1)与普通子程序编写规则相同;
    2)使用iret返回。

    二、编写应用程序

    1、与call调用子程序类似;
    2、使用int命令调用相应中断码的中断;
    3、可屏蔽中断只有在IF为1时才被响应。

    三、实例:

    编写、安装中断7ch的中断例程

    一、编写中断程序

    E:\mywork\asm\pd03.asm
    C:\>edit pd03.asm
    ; 功能:求一word型数据的平方
    ; 参数:(ax)=要计算的数据
    ; 返回值: dx,ax中存放结果的高16位和第16位
    assume cs:code
    
    code segment
    
    start:
    	; 安装数据
    	mov ax,cs
    	mov ds,ax
    	mov ax,0
    	mov es,ax
    	mov cx,offset int7chEnd-offset int7ch
    	mov si,offset int7ch
    	mov di,200h
    	cld
    	rep movsb
    
    	;写入中断向量表
    	mov ax,0
    	mov es,ax
    	mov word ptr es:[7ch*4],200h
    	mov word ptr es:[7ch*4+2],0
    	
    	mov ax,4c00h
    	int 21h
    
    int7ch:
    	mul ax
    	iret
    int7chEnd: nop
    
    code ends
    
    end start
    C:\>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39

    二、编写应用程序

    E:\mywork\asm\pd02.asm
    C:\>edit pd02.asm
    ; 求2*3456^2的值
    assume cs:code
    
    code segment
    
    start:
    	mov ax,3456
    	int 7ch
    	add ax,ax
    	adc dx,dx
    
    	mov ax,4c00h
    	int 21h
    
    code ends
    
    end start
    C:\>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    三、编译、连接、运行

    //先安装7ch中断程序pd03
    C:\>pd03
    //再调试应用程序pd02
    C:\>debug pd02.exe
    -u
    076A:0009 B8004C MOV AX,4C00
    -g 9
    AX=8000
    DX=016C
    076A:0009 B8004C MOV AX,4C00
    -q
    C:\>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    (全文完)

  • 相关阅读:
    Qt 非圆角图片裁剪为圆角图片
    12、Mybatis框架-1
    操作符keyof的作用是什么
    HBase优化
    05_模板引擎
    【pytorch】目标检测:YOLO的基本原理与YOLO系列的网络结构
    智能合约安全分析,假充值攻击如何突破交易所的防御?
    pytorch开发问题汇总
    Android studio主题样式(theme文件)的设置
    【docker:容器提交成镜像】
  • 原文地址:https://blog.csdn.net/ycjnx/article/details/133821210