. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验15,WINDOWS XP下没有调试成功  [待解决] 回复[ 3次 ]   点击[ 402次 ]  
aukeys
[帖 主]   [ 发表时间:2008-11-28 19:50 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-11-08 21:55
; Template for DOS .exe file


        assume  cs:cseg, ds:dseg, ss:sseg

        ; code
cseg    segment
start:
        ; ... put your code here ...
        mov ax,sseg
        mov ss,ax
        mov sp,100h
        
        push cs
        pop ds
        mov si,offset int9
        
        mov ax,0
        mov es,ax
        mov di,204h
        
        mov cx,offset int9_end-offset int9
        cld
        rep movsb
        
        push es:[9*4]
        pop es:[200h]
        push es:[9*4+2]
        pop es:[202h]
        
        cli
        mov word ptr es:[9*4],204h
        mov word ptr es:[9*4+2],0
        sti
        
        ; exit to DOS
        mov     ax, 4C00h
        int     21h

int9:
        push ax
        push bx
        push cx
        push es
        
        in al,60h
        pushf
        call word ptr es:[200]
        
        cmp al,9eh
        jne int9_ret
        
        mov ax,0b800h
        mov es,ax
        mov bx,1
        
        mov cx,2000

int9_s:
        mov byte ptr es:[bx],'A'
        add bx,2
        loop int9_s
        
int9_ret:
        pop es
        pop cx
        pop bx
        pop ax
        iret        
        
int9_end:nop

cseg    ends


        ; data
dseg    segment
        dw 10h dup(0)
        ; ...

dseg    ends


        ; stack
sseg    segment stack

        db      100h    dup(?)

sseg    ends
end start
abob
[第1楼]   [ 回复时间:2008-11-30 08:20 ]   [引用]   [回复]   [ top ] 
荣誉值:169
信誉值:0
注册日期:2008-08-19 16:07
??

出现了什么问题?尝试分析这个问题为什么出现了吗?对于分析是如何验证的?

虚拟dos下不行,是否需要在实dos下调试?(如果需要书上肯定是讲过)

只把代码贴上来找别人给调试没什么诚意啊 呵呵
aukeys
[第2楼]   [ 回复时间:2008-11-30 16:33 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-11-08 21:55
; Template for DOS .exe file


        assume  cs:cseg, ds:dseg, ss:sseg

        ; code
cseg    segment
start:
        ; ... put your code here ...
        mov ax,sseg
        mov ss,ax
        mov sp,100h
        
        push cs
        pop ds
        mov si,offset int9
        
        mov ax,0
        mov es,ax
        mov di,204h
        
        mov cx,offset int9_end-offset int9
        cld
        rep movsb
        
        push es:[9*4]
        pop es:[200h]
        push es:[9*4+2]
        pop es:[202h]
        
        cli
        mov word ptr es:[9*4],204h
        mov word ptr es:[9*4+2],0
        sti
        
        ; exit to DOS
        mov     ax, 4C00h
        int     21h

int9:
        push ax
        push bx
        push cx
        push es
        
        in al,60h
        pushf
        call word ptr cs:[200h]           ;这里以前是call word ptr es:[200h]  ,错了,现在改过来用cs 
        
        cmp al,9eh
        jne int9_ret
        
        mov ax,0b800h
        mov es,ax
        mov bx,0                              ;这里以前是mov bx,1,错了,应该是0每个字的低地址为ASCII码
        
        mov cx,2000

int9_s:
        mov byte ptr es:[bx],'A'
        add bx,2
        loop int9_s
        
int9_ret:
        pop es
        pop cx
        pop bx
        pop ax
        iret        
        
int9_end:nop

cseg    ends


        ; data
dseg    segment
        dw 10h dup(0)
        ; ...

dseg    ends


        ; stack
sseg    segment stack

        db      100h    dup(?)

sseg    ends
end start

程序改完了,还是不能在WINDOWS XP 下面调试成功
aukeys
[第3楼]   [ 回复时间:2008-11-30 16:52 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2008-11-08 21:55
; Template for DOS .exe file


        assume  cs:cseg, ds:dseg, ss:sseg

        ; code
cseg    segment
start:
        ; ... put your code here ...
        mov ax,sseg
        mov ss,ax
        mov sp,100h
        
        push cs
        pop ds
        mov si,offset int9
        
        mov ax,0
        mov es,ax
        mov di,204h
        
        mov cx,offset int9_end-offset int9
        cld
        rep movsb
        
        push es:[9*4]
        pop es:[200h]
        push es:[9*4+2]
        pop es:[202h]
        
        cli
        mov word ptr es:[9*4],204h
        mov word ptr es:[9*4+2],0
        sti
        
        ; exit to DOS
        mov     ax, 4C00h
        int     21h

int9:
        push ax
        push bx
        push cx
        push es
        
        in al,60h
        pushf
        call dword ptr cs:[200h] 
        
        cmp al,9eh
        jne int9_ret
        
        mov ax,0b800h
        mov es,ax
        mov bx,0
        
        mov cx,2000

int9_s:
        mov byte ptr es:[bx],'A'
        add bx,2
        loop int9_s
        
int9_ret:
        pop es
        pop cx
        pop bx
        pop ax
        iret        
        
int9_end:nop

cseg    ends


        ; data
dseg    segment
        dw 10h dup(0)
        ; ...

dseg    ends


        ; stack
sseg    segment stack

        db      100h    dup(?)

sseg    ends
end start

调试成功了。
总结:有时候写程序不能粗心大意,要好好检查,我以上的问题主要有2个:
1.  call word ptr es:[200h]           ;这里应该是dword双字才能正确调用,并且要用cs段,因为此时cs段地址为0,要用call dword ptr cs:[200h],才能正确访问之前的int 9h中断。
2.  mov bx,1                              ;这里设置成了高地址,应该是mov bx,0,每个字的低地址为ASCII码
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved