请求帮忙。。。谢谢!~
我这个程序是从键盘接收对应的扫描码,要求把接收到的扫描码转换为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]]