|
hao123com
新手上路
积分 8
发帖 3
注册 2007-10-27
状态 离线
|
『楼 主』:
替换键盘中断并显示按键编码,有点小问题,帮忙看下
data SEGMENT
data ENDS
stack1 SEGMENT para stack
stack1 ENDS
code SEGMENT
ASSUME CS:code,DS:data,ES:data,SS:stack1
ORG 100h
start:
hlt
mov ax,04f02h
mov bx,101h
int 10h
xiandian0:
call xiandian
;jmp xiandian0
MOV CL,09h ;设成灰底红字
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,0
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,1
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,2
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,3
int 10h
call qingping0
call xianshibiaozhi
call xianshiint9 ;显示当前中断9向量地址
beifenkeyint: ;备份键盘中断转向(向量)地址
sub AX,AX
MOV DS,AX
MOV AX,WORD PTR DS:[24h]
MOV WORD PTR CS:[200h],AX
MOV AX,WORD PTR DS:[26h]
MOV WORD PTR CS:[202h],AX
;重新设置键盘中断转向(向量)地址
MOV AX,300h
MOV WORD PTR DS:[24h],AX
MOV AX,CS
MOV WORD PTR DS:[26h],AX
MOV AX,ES
MOV DS,AX
call xianshiint9 ;显示当前中断9向量地址
sti
;等待键盘输入
waitinkey:
MOV AL,cS:[20ah] ;检测是否有键摁下
CMP AL,81h
JZ exitchengxu ;ESC键按下则退出
cmp al,83h
jz qingping1
cmp al,85h
jz zhuliu
MOV AL,cS:[20ah]
cmp al,04h
jz xianshi16she
cmp al,0 ;检测是否有其他键摁下
jnz keyover
JMP WAITinkey
keyover:
MOV AL,20H
OUT 20H,AL
;call xianshibiaozhi
;call xianshiint9 ;显示有键摁下后程序返回的中断9向量地址
mov al,0 ;清除键码识别区
mov cs:[20ah],al
;call xiandian
jmp waitinkey
qingping1:
mov cl,074h
XOR AL,AL
mov cs:[20bh],al
call qingping0
jmp keyover
xianshi16she:
mov al,1
mov cs:[20bh],al
call qingping0
jmp keyover
zhuliu:
MOV AL,20H
OUT 20H,AL
sti
;mov ah,31h
mov ax,3h
int 10h
int 20h
exitchengxu: ;恢复键盘中断转向(向量)地址并退出程序
cli
XOR AX,AX
MOV DS,AX
MOV AX,WORD PTR ES:[200h]
MOV WORD PTR DS:[24h],AX
MOV AX,WORD PTR ES:[202h]
MOV WORD PTR DS:[26h],AX
MOV AX,ES
MOV DS,AX
call xianshiint9 ;显示程序退出以前中断9是否正常恢复
sti
MOV AL,20h
OUT 20h,AL
call xianshibiaozhi
SUB AL,AL
mov cs:[20bh],al
MOV CL,7 ;恢复背景
call qingping0
mov ax,3h
int 10h
sti
int 20h ; 退出程序
ORG start+100h
c1 DB 10h DUP(?) ;建立临时数据存储区
ORG start+200h
keyint9: ;键盘中断9处理程序
push ax
;call xianshi64h1
IN AL,60h ;读取键盘扫描码
MOV ES:[20ah],AL ;将扫描码存入按键识别区
call xianshi
;call fenjiexianshi ;显示扫描码
;mov al,0aah
;call xianshi
;call xianshiint9 ;显示当前中断9向量地址
;call xianshi64h1
pop ax
IRET ;键盘中断返回
bijiao: ;比较
CMP AL,9
JG jia41h
ADD AL,30H
RET
jia41h:
SUB AL,0ah
;ADD AL,41h
RET
xianshi: ;显示
PUSH DS
PUSH Ax
MOV AX,0A000h
MOV DS,AX
mov ax,word ptr es:[208h]
mov di,ax
CMP Di,0ffffh
Jz diqingling
jixuxianshi:
POP Ax
MOV DS:[Di],AL
inc Di ;字符显示在偶地址,背景显示在奇地址
mov ax,di
mov word ptr es:[208h],ax
POP DS
RET
Diqingling:
xor DI,di
JMP jixuxianshi
fenjiexianshi: ;分解显示
;显示AL的高4位16进制代码
MOV BL,AL
MOV CL,4
ROR AL,CL
AND AL,0fh
CALL bijiao
CALL xianshi
;显示AL的低4位16进制代码
MOV AL,BL
AND AL,0fh
CALL bijiao
CALL xianshi
ret
xianshiint9: ;显示中断9
SUB AX,AX
mov ds,ax
XOR di,DI
mov al,ds:[27h]
call fenjiexianshi
mov al,ds:[26h]
call fenjiexianshi
mov al,ds:[25h]
call fenjiexianshi
mov al,ds:[24h]
call fenjiexianshi
mov al,0aah
call xianshi
ret
xianshibiaozhi: ;显示状态标志寄存器状态
pushf
pop ax
mov dx,ax
mov al,dh
call fenjiexianshi ;调分解显示,显示状态标志寄存器高8位状态
mov al,dl
call fenjiexianshi ;调分解显示,显示状态标志寄存器低8位状态
mov al,20h
call xianshi
ret
qingping0:
MOV BX,0H
MOV aX,0A000h ;输入字符显示缓冲区启始段地址b800h
MOV DS,aX
qingping: ;清屏幕
MOV AL,cl
MOV DS:[BX],AL
dec BX
mov al,cs:[20bh]
cmp al,1
jz cladd1
jixucl:
CMP bx,0h
Jne qingping
SUB Ax,Ax
mov es:[20bh],al
dec cl
ret
cladd1:
add cl,1h ;此语句去掉注释可实现16色背景
;and cl,77h
jmp jixucl
xianshi64h1:
in al,64h
and al,3
add al,30h
call xianshi
mov al,20h
call xianshi
ret
xiandian:
PUSH DS
PUSH ES
push dx
MOV DX,0b000H
mov ax,4f05h
mov bx,01
int 10h
;MOV ES,DX
;MOV DX,80
;MUL DX
;MOV DI,AX
;MOV AX,BX
;MOV CL,3
;SHR AX,CL
;ADD DI,AX ;DI=BYTE NUM
;MOV CL,BL
;AND CL,7
;XOR CL,7
MOV BL,0ffH
;SHR BL,CL
MOV DX,3C4H
MOV AL,2
OUT DX,AL
INC DX
MOV AL,0ffH
OUT DX,AL
MOV DX,3CEH
MOV AL,5H
OUT DX,AL
INC DX
MOV AL,2
OUT DX,AL
;dec dx
;mov al,1
;out dx,al
;inc dx
;mov al,0h
;out dx,al
DEC DX
MOV AL,8
OUT DX,AL
INC DX
MOV AL,BL
OUT DX,AL
pop dx
POP ES
POP DS
RET
code ENDS
END start
|
|
2007-10-27 21:34 |
|
|
hao123com
新手上路
积分 8
发帖 3
注册 2007-10-27
状态 离线
|
『第
2 楼』:
我希望有汉语汇编语言
我这个程序有点问题,各位大大帮帮忙吧-------
.386
data SEGMENT
data ENDS
stack1 SEGMENT para stack
stack1 ENDS
code SEGMENT
ASSUME CS:code,DS:data,ES:data,SS:stack1
ORG 100h
start:
mov ax,04f02h
mov bx,111h
int 10h
xiandian0:
call xiandian
;jmp xiandian0
MOV CL,09h ;设成灰底红字
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,0
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,1
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,2
int 10h
call qingping0
mov al,1
mov es:[20bh],al
mov ax,070h ;设置字符显示起始位置
mov word ptr es:[208h],ax
mov ax,4f05h
mov bx,0
mov dx,3
int 10h
call qingping0
call xianshibiaozhi
call xianshiint9 ;显示当前中断9向量地址
beifenkeyint: ;备份键盘中断转向(向量)地址
sub AX,AX
MOV DS,AX
MOV AX,WORD PTR DS:[24h]
MOV WORD PTR CS:[200h],AX
MOV AX,WORD PTR DS:[26h]
MOV WORD PTR CS:[202h],AX
;重新设置键盘中断转向(向量)地址
MOV AX,300h
MOV WORD PTR DS:[24h],AX
MOV AX,CS
MOV WORD PTR DS:[26h],AX
MOV AX,ES
MOV DS,AX
call xianshiint9 ;显示当前中断9向量地址
sti
;等待键盘输入
waitinkey:
MOV AL,cS:[20ah] ;检测是否有键摁下
CMP AL,81h
JZ exitchengxu ;ESC键按下则退出
cmp al,83h
jz qingping1
MOV AL,cS:[20ah]
cmp al,04h
jz xianshi16she
cmp al,0 ;检测是否有其他键摁下
jnz keyover
JMP WAITinkey
keyover:
MOV AL,20H
OUT 20H,AL
;call xianshibiaozhi
;call xianshiint9 ;显示有键摁下后程序返回的中断9向量地址
mov al,0 ;清除键码识别区
mov cs:[20ah],al
;call xiandian
jmp waitinkey
qingping1:
mov cl,074h
XOR AL,AL
mov cs:[20bh],al
call qingping0
jmp keyover
xianshi16she:
mov al,1
mov cs:[20bh],al
call qingping0
jmp keyover
exitchengxu: ;恢复键盘中断转向(向量)地址并退出程序
cli
XOR AX,AX
MOV DS,AX
MOV AX,WORD PTR ES:[200h]
MOV WORD PTR DS:[24h],AX
MOV AX,WORD PTR ES:[202h]
MOV WORD PTR DS:[26h],AX
MOV AX,ES
MOV DS,AX
call xianshiint9 ;显示程序退出以前中断9是否正常恢复
MOV AL,20H
OUT 20H,AL
sti
call xianshibiaozhi
SUB AL,AL
mov cs:[20bh],al
MOV CL,7 ;恢复背景
call qingping0
mov ax,3h
int 10h
INT 20h ; 退出程序
ORG start+100h
c1 DB 10h DUP(?) ;建立临时数据存储区
ORG start+200h
keyint9: ;键盘中断9处理程序
push ax
;call xianshi64h1
IN AL,60h ;读取键盘扫描码
MOV ES:[20ah],AL ;将扫描码存入按键识别区
call xianshi
;call fenjiexianshi ;显示扫描码
;mov al,0aah
;call xianshi
;call xianshiint9 ;显示当前中断9向量地址
;call xianshi64h1
pop ax
IRET ;键盘中断返回
bijiao: ;比较
CMP AL,9
JG jia41h
ADD AL,30H
RET
jia41h:
SUB AL,0ah
;ADD AL,41h
RET
xianshi: ;显示
PUSH DS
PUSH Ax
MOV AX,0A000h
MOV DS,AX
mov ax,word ptr es:[208h]
mov di,ax
CMP Di,0ffffh
Jz diqingling
jixuxianshi:
POP Ax
MOV DS:[Di],AL
inc Di ;字符显示在偶地址,背景显示在奇地址
mov ax,di
mov word ptr es:[208h],ax
POP DS
RET
Diqingling:
xor DI,di
JMP jixuxianshi
fenjiexianshi: ;分解显示
;显示AL的高4位16进制代码
MOV BL,AL
MOV CL,4
ROR AL,CL
AND AL,0fh
CALL bijiao
CALL xianshi
;显示AL的低4位16进制代码
MOV AL,BL
AND AL,0fh
CALL bijiao
CALL xianshi
ret
xianshiint9: ;显示中断9
SUB AX,AX
mov ds,ax
XOR di,DI
mov al,ds:[27h]
call fenjiexianshi
mov al,ds:[26h]
call fenjiexianshi
mov al,ds:[25h]
call fenjiexianshi
mov al,ds:[24h]
call fenjiexianshi
mov al,0aah
call xianshi
ret
xianshibiaozhi: ;显示状态标志寄存器状态
pushf
pop ax
mov dx,ax
mov al,dh
call fenjiexianshi ;调分解显示,显示状态标志寄存器高8位状态
mov al,dl
call fenjiexianshi ;调分解显示,显示状态标志寄存器低8位状态
mov al,20h
call xianshi
ret
qingping0:
MOV BX,0H
MOV aX,0A000h ;输入字符显示缓冲区启始段地址b800h
MOV DS,aX
qingping: ;清屏幕
MOV AL,cl
MOV DS:[BX],AL
dec BX
mov al,cs:[20bh]
cmp al,1
jz cladd1
jixucl:
CMP bx,0h
Jne qingping
SUB Ax,Ax
mov es:[20bh],al
dec cl
ret
cladd1:
add cl,1h ;此语句去掉注释可实现16色背景
;and cl,77h
jmp jixucl
xianshi64h1:
in al,64h
and al,3
add al,30h
call xianshi
mov al,20h
call xianshi
ret
xiandian:
PUSH DS
PUSH ES
push dx
MOV DX,0b000H
mov ax,4f05h
mov bx,01
int 10h
;MOV ES,DX
;MOV DX,80
;MUL DX
;MOV DI,AX
;MOV AX,BX
;MOV CL,3
;SHR AX,CL
;ADD DI,AX ;DI=BYTE NUM
;MOV CL,BL
;AND CL,7
;XOR CL,7
MOV BL,0ffH
;SHR BL,CL
MOV DX,3C4H
MOV AL,2
OUT DX,AL
INC DX
MOV AL,0ffH
OUT DX,AL
MOV DX,3CEH
MOV AL,5H
OUT DX,AL
INC DX
MOV AL,2
OUT DX,AL
;dec dx
;mov al,1
;out dx,al
;inc dx
;mov al,0h
;out dx,al
DEC DX
MOV AL,8
OUT DX,AL
INC DX
MOV AL,BL
OUT DX,AL
pop dx
POP ES
POP DS
RET
code ENDS
END start
|
|
2007-10-30 21:52 |
|
|
hao123com
新手上路
积分 8
发帖 3
注册 2007-10-27
状态 离线
|
『第
3 楼』:
反对兼容微软dos---做个汉语编程入门dos更实用
反对兼容微软dos---做个汉语编程入门dos更实用,我这个小学生通过自学能用散件组装电视,电脑编程资料希望能通俗一些,容易理解一些,谁能完成我叩谢他三天三夜
|
|
2007-10-30 22:05 |
|
|