当前位置: 代码迷 >> 汇编语言 >> 安装中断显示乱码的有关问题
  详细解决方案

安装中断显示乱码的有关问题

热度:1844   发布时间:2013-02-26 00:00:00.0
安装中断显示乱码的问题
;安装0号中断,在屏幕中央显示overflow!
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov ax,0
mov es,ax
mov si,offset do0
mov di,0200h
mov cx,offset do0end - offset do0
cld
rep movsb ;copy data
;set interrupt vector:
mov ax,0
mov es,ax
mov word ptr es:[0*4],0200h
mov word ptr es:[0*4+2],0

do0:jmp short do0start
db 'overflow!'
do0start:

mov ax,cs
mov ds,ax
mov si,0202h
mov ax,0b800h
mov es,ax
mov di,12*160+36*2
mov cx,9
s:
mov al,ds:[si]
mov es:[di],al
inc si
add di,2
loop s
do0end:nop
mov ax,4c00h
int 21h
code ends
end start
在命令行下运行,显示:
ΦQºâ─?^ïσ


------解决方案--------------------------------------------------------
mov word ptr es:[0*4+2],0
这句后面加返回语句
mov ax,4c00h
int 21h
------解决方案--------------------------------------------------------
do0end:nop
mov ax,4c00h
int 21h
code ends
end start

换成

mov ax,4c00h
int 21h
do0end:nop
code ends
end start
------解决方案--------------------------------------------------------
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov ax,0
mov es,ax
mov si,offset do0
mov di,0200h
mov cx,offset do0end - offset do0
cld
rep movsb ;copy data
;set interrupt vector:
mov ax,0
mov es,ax
mov word ptr es:[0*4],0200h
mov word ptr es:[0*4+2],0

mov ax,0ffffh ;除下看看
mov bx,1
div bl


do0:jmp short do0start
db 'overflow!'
do0start:

mov ax,cs
mov ds,ax
mov si,0202h
mov ax,0b800h
mov es,ax
mov di,12*160+36*2
mov cx,9
s:
mov al,ds:[si]
mov es:[di],al
inc si
add di,2
loop s
mov ax,4c00h ;返回DOS调上来
int 21h
do0end:nop

code ends
end start
------解决方案--------------------------------------------------------
;;安装0号中断,在屏幕中央显示overflow!;;

code segment
assume cs:code,ds:code
org 100h
start:
mov ax,code
mov ds,ax
call load ;修改0H中断服务程序
key:
int 0h ;调用该中断,在屏幕中央显示overflow!
mov ah,0
int 16h
lea dx,msg
mov ah,9
int 21h
mov ah,1 ;等待
int 21h
mov ah,4ch
int 21h
;
msg db 0dh,0ah,' Press any key to quit ...$'
;
load: ;装入0h中断
cli
xor ax,ax
mov es,ax
xor di,di
lea bx,@int
mov es:[di],bx
add di,2
push cs
pop ax
mov es:[di],ax
sti
push cs
pop es
ret

@int: ;中断进程
jmp int_0h
nop
Str db 'overflow!'
cnt equ $-Str
nop
int_0h:
sti
push ds
push dx
push ax
;
push cs
pop ds
mov ax,3
int 10h
mov ax,0b800h
mov es,ax
cld
mov si,offset Str
mov di,(80-9)/2+25/2*80*2
mov cx,cnt
mov ah,7
lodsb
stosw
loop $-2
;
pop ax
pop dx
pop ds
cli
iret

code ends
end start

------解决方案--------------------------------------------------------
1.开始cli,关中断,装入中断的通用语句,本例也可省去.
2.lodsb
stosw
loop $-2
等效于:
Here:
lodsb
stosw
loop Here
省用标记.

------解决方案--------------------------------------------------------
9楼要用MASM5.0编译,如用MASM6.1编译,可作如下修改:
;;安装0号中断,在屏幕中央显示overflow!;;

.286
.model tiny
code segment byte public 'CODE' use16
assume cs:code, ds:code
org 100h
start:
push cs
pop ds
call load ;修改0H中断服务程序
key:
int 0h ;调用该中断,在屏幕中央显示overflow!
mov ah,0
  相关解决方案