中断程序设计_第1页
中断程序设计_第2页
中断程序设计_第3页
中断程序设计_第4页
中断程序设计_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、汇 编 语 言 实 验 报 告Assembly Language Programming Lab Reports_班级: 姓名学号: 实验日期:学院: 专业:实验顺序: 原创:_ 实验名称:中断程序设计 实验分数:_ 考评日期:_ 指导教师: _实验目的1 掌握中断的类型,软件中断和硬件终端。2 掌握中断处理的过程,理解中断类型,中断向量。3 掌握系系统中断以及功能调用。4 可以自己设计中断程序_实验环境操作系统:windows 8编译程序:masm 5.0_实验步骤及结果分析1.设计自己的中断.model small.stack .codemess db 'press 1

2、to use selfintereput$'mess2 db 'wrong'mess3 db 'My name is ZhangXu$'main proc farstart:mov ax,codemov ds,axmov dx,offset mynamemov ax,seg mynamemov ds,axmov ah,60hmov ah,25hint 21h ;设置中断向量mov dx,offset messmov ax,seg messmov ds,axmov ah,9hint 21hmov dl,0dhmov ah,2int 21hmov dl,0a

3、hint 21hmov ah,1int 21hcmp al,'1'jnz m2mov ah,60hint 21hjmp nextm2:mov dl,0dhmov ah,2int 21hmov dl,0ahint 21hmov dx,offset mess2mov ax,seg mess2mov ds,axmov ah,9hint 21hnext:main endpmyname proc farstimov dl,0dhmov ah,2int 21hmov dl,0ahint 21hmov cx,10bef:mov dl,'*'mov ah,2int 21hloo

4、p befmov ax,seg mess3mov ax,dsmov dx,offset mess3mov ah,9int 21hmov cx,10aft:mov dl,'*'mov ah,2int 21hloop aftcliiretmyname endpend start2,对原有的中断进行修改.model small.stack.codemess1 db 0ah,0dh,'enter interrupt!',0ah,0dh,'$'mess2 db 0ah,0dh,'exit interrupt!$'mess3 db 0ah,0

5、dh,'Continue or Quit(c/q)?$'主程序main proc farstart:mov ax,codemov ds,ax;中断设置;取出原中断向量mov al,0mov ah,35h;取出原来的0号中断向量int 21h ;放在ES:BX中push es;入栈保存push bxpush ds;设置新的中断向量;相当于25h号功能mov dx,offset showerr;获得子程序偏移地址mov ax,seg showerr;获得子程序段地址mov ds,axmov ax,0mov es,ax;0段,向量表mov bx,0;现在的0号mov cl,2shl

6、bx,clmov word ptr es:bx,dx;中断向量放入中断向量表中mov word ptr es:bx+2,ds;应用部分conti:mov dx,offset mess1;显示提示1mov ah,9int 21hint 0;触发0号中断mov dx,offset mess2;显示提示2mov ah,9int 21hmov ax,15mov bl,0idiv bl;除0,触发0号中断mov dx,offset mess3;显示提示3mov ah,9int 21hmov ah,1;输入选择int 21hcmp al,'c'je contiquit:pop ds;弹出保

7、存的数据pop bxpop esmov al,0;恢复原来的0号mov ah,25h;中断向量放入中断向量表中int 21hmov ax,4c00h;返回DOSint 21hmain endp ;中断子程序showerr proc near showbegin:jmp short show_str;跳过数据定义a1 db 'Attention! error.'显示信息与子程序放在一起,便于以后驻留a2 db 0show_str:mov ax,code;数据段与代码段同段mov ds,axsti;开中断mov dh,22;行 mov dl,24;列mov bl,1;属性mov si,offset a1mov ax,0b800h;显存首址mov es,axmov ax,160mul dh;行号*160mov di,ax;起始行位置sal dl,1mov dh,0add di,dx;+列号mov cx,a2-a1;字符串长度let1:;循环写字符和属性到显存mov al,simov es:di,almov byte ptr es:di+1,blinc siinc bl;改变属性

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论