. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->外中断
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验15  [待解决] 回复[ 4次 ]   点击[ 350次 ]  
yxinxin1989
[帖 主]   [ 发表时间:2011-04-03 21:34 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-02-14 10:53
;安装一个新的int9中断例程,功能:在DOS下,按下“A”键后,除非不再松开,如果松开,就显示满屏幕的
;“A”;其他的键照常处理。
;我觉得我的程序思路都是对的啊,始终找不出来 到底是哪里出了错。
;高手们帮我看看吧

assume cs:code,ss:stack
stack segment
        db 128 dup (0)
stack ends
data segment
        dw 0,0
data ends
code segment
start:mov ax,stack
      mov ss,ax
      mov sp,128
     
      mov ax,data
      mov ds,ax
 
      mov ax,0
      mov es,ax
 
      push es:[9*4]
      pop ds:[0]
      push es:[9*4+2]
      pop ds:[2]
 
      cli
      mov word ptr es:[9*4],offset int9
      mov es:[9*4+2],cs
      sti
 
      mov ah,0
      mov cx,120
    l:int 60h      ;进行120次读取BIOSS键盘缓冲区
      loop l         

      cli     
      push ds:[0]
      pop es:[9*4] 
      push ds:[2]
      pop es:[9*4+2]
      sti
    
      mov ax,4c00h
      int 21h
;--------------------------------------------------------------
int9:push ax
     push bx
     push cx
     push es
 
     in al,60h
     
     pushf
     call dword ptr ds:[0]
     
     cmp al,9eh
     jne int9ret
     mov ax,0b800h
     mov es,ax
     mov bx,0
     mov cx,80*25
   s:mov byte ptr es:[bx],'A'
     mov byte ptr es:[bx+1],2
     add bx,2
     loop s
     
int9ret:pop es
        pop cx
        pop bx
        pop ax
        ret 
;------------------------------------------------------------
code ends 
end start
hoxily
[第1楼]   [ 回复时间:2011-04-28 15:35 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-03-16 19:25
回复:[贴 主]
------------------
 l:int 60h      ;进行120次读取BIOSS键盘缓冲区
   loop l  
你这里为什么要这么做呢?int 60h意思是引发60h号中断.60h号中断与键盘读取有关吗?
还有,读取120次有是为了什么?
只要键盘没有引发9h号中断,即说明没有按键按下或松开的事件发生.
那么用于键盘沟通的60h号端口所对应的存储值就没变.
hoxily
[第2楼]   [ 回复时间:2011-04-28 15:38 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-03-16 19:25
;晒一下我的代码.
;按A键后除非不再松开,如果松开就显示满屏幕的字符'A',其他键照常处理.
maxTimes equ 0ffffh
stack segment
    byte 128 dup(0)
stack ends

code segment
    start:
        mov ax,stack
        mov ss,ax
        mov sp,128
        ;initial work routine
        
        push cs
        pop ds
        
        mov ax,0
        mov es,ax
        mov si,offset myint9
        mov di,206h
        mov cx,offset myint9end -offset myint9
        cld
        rep movsb
        
        push es:[9*4]
        pop es:[200h]
        push es:[9*4+2]
        pop es:[202h]
        ;store previous int 9 's entry
        
        cli
        mov word ptr es:[9*4],206h;留出0:204用于保存上次键盘中断的扫描码
        mov word ptr es:[9*4+2],0
        ;set new int 9 's door
        sti
        mov ax,4c00h
        int 21h
    myint9:
            push ax
            push bx
            push cx
            push dx
            push es
            in al,60h
            mov dl,cs:[204h];取得上次键盘中断的扫描码
            pushf
            call dword ptr cs:[200h]
            
            cmp al,9eh;'A'的断码
            jne myint9ret
            cmp dl,1eh;'A'的通码
            jne myint9ret
            mov ax,0b800h
            mov es,ax
            mov bx,0
            mov cx,2000
        myint9_s:
            mov byte ptr es:[bx],'A'
            add bx,2
            loop myint9_s
        myint9ret:
            mov cs:[204h],al;更新键盘中断的扫描码
            pop es
            pop dx
            pop cx
            pop bx
            pop ax
            iret
    myint9end:
            nop
code ends
end start
awangxuana
[第3楼]   [ 回复时间:2011-09-21 12:38 ]   [引用]   [回复]   [ top ] 
荣誉值:0
信誉值:0
注册日期:2011-09-12 11:45
assume cs:code

stack segment
        db 128 dup (0)
stack ends

code segment
start:        mov ax,stack
                mov ss,ax
                mov sp,128
                
                mov ax,0
                mov es,ax
                push es:[9*4]
                pop es:[200h]
                push es:[9*4+2]
                pop es:[202h]
                
                push cs
                pop ds
                
                mov si,offset int9
                
                mov di,0204h
                
                cld
                mov cx,offset int9end-offset int9
                rep movsb
                
                cli
                mov word ptr es:[9*4],204h
                mov word ptr es:[9*4+2],0
                sti
        
                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 int9iret
                
                
                mov ax,0b800h
                mov es,ax
                mov bx,0
                mov cx,2000
s:                mov byte ptr es:[bx],'A'
                add bx,2
                loop s
        
                
int9iret:pop es
                pop cx
                pop bx
                pop ax
                iret

int9end: nop

code ends
end start
chinatree
[第4楼]   [ 回复时间:2011-09-21 13:22 ]   [引用]   [回复]   [ top ] 
荣誉值:118
信誉值:0
注册日期:2011-07-07 22:59
楼主的代码把这几句删掉就差不多了,最好在来个循环让它停一会,不然一运行就退出了。
mov ah,0
      mov cx,120
    l:int 60h      ;进行120次读取BIOSS键盘缓冲区
      loop l
需要登录后才能回帖 -->> 请单击此处登录
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved