assume cs:code
code segment
data segment
data ends
start:
mov ax,cs ;让DS代表code段的短地址
mov ds,ax ;以从code段复制中断处理程序
mov si,offset do0 ;(si) = 传送原始位置的起始偏移地址
mov ax,0
mov es,ax
mov di,200h ;设置es:di指向目的地址
mov cx,offset do0end-offset do0 ;设置cx为传输长度
cld ; DF 标志位置零, 设置传输方向为正
rep movsb ;cx个字节的内容从ds:si复制到es:di
;设置中断向量表
mov ax,0
mov es,ax ;[es] = 0
mov word ptr es:[0*4],200h ;设置0号中断的偏移地址为200h
mov word ptr es:[0*4+2],0 ;设置0号中断的短地址为0
;测试新的0号中断
mov ax,data
mov ds,ax
mov ax,50h
mov cl,0
div cl
mov ax,4c00h
int 21h
mov ax,4c00h
do0:
jmp short do0start
db 'devide error!'
do0start:
mov ax,0
mov ds,ax
mov si,202h ;设置ds:si 指向字符串
mov ax,0b00h
mov es,ax
mov di,12*160+36*2
mov cx,13
s: mov al,[si]
mov es:[di],al
inc si
add si,2
loop s
mov ax,4c00h
int 21h
do0end:
nop
code ends
end start