中断程序的设计说明

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

汇编语言实验报告

Assembly Language Programming Lab Reports

______________________________________________________________________________ 班级:学号:实验日期:

学院:专业:

实验顺序:原创:___ 实验名称:中断程序设计

实验分数:_______ 考评日期:________ 指导教师:

______________________________________________________________________________ 实验目的

一.掌握中断的类型,软件中断和硬件终端。

二.掌握中断处理的过程,理解中断类型,中断向量。

三.掌握系系统中断以及功能调用。

四.可以自己设计中断程序

______________________________________________________________________________实验环境

操作系统:windows 8

编译程序:masm 5.0

______________________________________________________________________________实验步骤及结果分析

1.设计自己的中断

.model small

.stack

.code

mess db 'press 1 to use selfintereput$'

mess2 db 'wrong'

mess3 db 'My name is ZhangXu$'

main proc far

start:

mov ax,code

mov ds,ax

mov dx,offset myname

mov ax,seg myname

mov ds,ax

mov ah,60h

mov ah,25h

int 21h ;设置中断向量

mov dx,offset mess

mov ax,seg mess

mov ds,ax

mov ah,9h

int 21h

mov dl,0dh

mov ah,2

int 21h

mov dl,0ah

int 21h

mov ah,1

int 21h

cmp al,'1'

jnz m2

mov ah,60h

int 21h

jmp next

m2:

mov dl,0dh

mov ah,2

int 21h

mov dl,0ah

int 21h

mov dx,offset mess2 mov ax,seg mess2 mov ds,ax

mov ah,9h

int 21h

next:

main endp

myname proc far

sti

mov dl,0dh

mov ah,2

int 21h

mov dl,0ah

int 21h

mov cx,10

bef:

mov dl,'*'

mov ah,2

int 21h

loop bef

mov ax,seg mess3

mov ax,ds

mov dx,offset mess3 mov ah,9

int 21h

mov cx,10

aft:

mov dl,'*'

mov ah,2

int 21h

loop aft

cli

iret

myname endp

end start

2,对原有的中断进行修改.model small

.code

mess1 db 0ah,0dh,'enter interrupt!',0ah,0dh,'$'

mess2 db 0ah,0dh,'exit interrupt!$'

mess3 db 0ah,0dh,'Continue or Quit(c/q)?$'

;主程序

main proc far

start:

mov ax,code

mov ds,ax

;中断设置

;取出原中断向量

mov al,0

mov ah,35h ;取出原来的0号中断向量

int 21h ;放在ES:BX中

push es ;入栈保存

push bx

push ds

;设置新的中断向量;相当于25h号功能

mov dx,offset showerr ;获得子程序偏移地址

mov ax,seg showerr ;获得子程序段地址

mov ds,ax

mov ax,0

mov es,ax ;0段,向量表

mov bx,0 ;现在的0号

mov cl,2

shl bx,cl

mov word ptr es:[bx],dx ;中断向量放入中断向量表中mov word ptr es:[bx+2],ds

;应用部分

conti:

mov dx,offset mess1 ;显示提示1

mov ah,9

int 21h

int 0 ;触发0号中断

mov dx,offset mess2 ;显示提示2

mov ah,9

int 21h

mov ax,15

mov bl,0

idiv bl ;除0,触发0号中断

mov dx,offset mess3 ;显示提示3

mov ah,9

相关文档
最新文档