| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 775 人关注过本帖
标题:请求帮忙。。。谢谢!~
取消只看楼主 加入收藏
don940
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-1-14
收藏
 问题点数:0 回复次数:0 
请求帮忙。。。谢谢!~
我这个程序是从键盘接收对应的扫描码,要求把接收到的扫描码转换为ASCII码。
我现在需要的是把程序修改成1、CR两个字符所对应的扫描码,转换为ASCII码。。。谢谢!!~
万分感激。。。

           .model         small
               .386
ocw1           equ           21h
ocw2           equ           20h
kdr           equ         60h
kcr            equ           64h
           .stack         40h
           .data
vector           byte         4 dup (?)
count          word         ?
scancode      byte         20h dup (0)
ascancode       byte           20h  dup(0)
buf_scan          word          ?
           .code
;
start:           mov         ax,@data
           mov         ds,ax
;
     ;initializing
;

               lea           ax,scancode
               mov           buf_scan,ax
               mov           count,0
;
         ;read and save old interrupt vector
;
               mov           ax,0
               mov           es,ax
           mov         si,09h*4
           lea         di,vector
               mov           edx,es:[si]
           mov         [di],edx
;
         ;set up new interrrupt vector
;
           lea         di,kintsvr
               mov           es:[si],di
               inc           si
               inc           si
           mov         ax,seg kintsvr
           mov         es:[si],ax
;
      ;activate 8259A interrupt
;
           cli
               mov           dx,ocw1
           in         al,dx
           and         al,0fdh
           out         dx,al
           sti
;
next:           hlt
           cmp         count,0ah
           jb         next
;
          ;close 8259A interrupt
;
               cli
               mov           dx,ocw1
               in            al,dx
           or         al,2h
               out           dx,al
           sti
;
          ;restore old interrupt vector
;
               mov           ax,0
               mov           es,ax
           mov         si,9h*4
           lea         di,vector
           mov         edx,[di]
               mov           es:[si],edx
;
           lea         bx,scancode
           lea         si,ascancode
           mov         count,0
           mov         ax,0
next1:           mov         cx,3h
           cmp         count,0ah
           jz         go
           mov         al,[bx]
           cmp         al,0bh
           jz         next2
           cmp         al,1ch
           jz         next3
           add         al,2fh
           add         count,2
           mov         [si],al
           add         bx,2
           inc         si
           loop         next1
next2:           mov         al,30h
           mov         [si],al
           add         bx,2
           inc         si
           add         count,2
           loop         next1
next3:           mov         al,0dh
           mov         [si],al
           add         bx,2
           inc         si
           add         count,2
           loop         next1
go:        .exit
           nop
           nop
;
;*******************************************************************
;*       the interrupt server                    *
;*******************************************************************
kintsvr           proc         near
;
               mov           ax,@data
               mov           ds,ax
;
               push          ax
           push         bx
               push          dx
;
          ;one scan code is received into register al
;
               mov           dx,kdr          
           in         al,dx
               push          ax
               mov           dx,kcr
               in            al,dx
               mov           ah,al
               or            al,80h
               out           dx,al
               mov           al,ah
               out           dx,al
               pop           ax
;
          ;(al) is moved to buffer
;
           mov         bx,buf_scan
           mov         [bx],al
               inc           bx
               mov           buf_scan,bx
           inc         count
;
          ;end of interrupt
;
               cli
               mov           dx,ocw2
               mov           al,20h
               out           dx,al
;
               pop           dx
           pop         bx
               pop           ax
;
           iret
;
kintsvr           endp
;
           end         start

[[italic] 本帖最后由 don940 于 2008-1-14 17:33 编辑 [/italic]]
搜索更多相关主题的帖子: 请求 
2008-01-14 17:31
快速回复:请求帮忙。。。谢谢!~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016376 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved