需要帮助,在MS-DOS中钩新的键盘中断 [英] Need help hooking new keyboard interrupt in MS-DOS
问题描述
我正在为装配课做作业.
I am working on an assignment for an assembly class.
我以前设法使计时器中断显示并在每个刻度上更新一个时钟".
I have previously managed to make my timer interrupt display and update a 'clock' at every tick.
我正在尝试使用这些知识来替换键盘中断.但是,即使我注释掉新键盘中断处理程序的安装,我的程序也会干扰MS-DOS活动(即无法运行任何可执行文件,只能使用'dir','cd'和类似命令):
I am attempting to use this knowledge to replace my keyboard interrupt. But even when I comment out the installation of the new keyboard interrupt handler, my program is interfering with MS-DOS activities (i.e. cannot run any executables, can only use 'dir', 'cd' and similar commands):
.model tiny
.8086
.code
org 100h
start:
jmp setup
new_key PROC
jmp cs: old_key
new_key ENDP
setup:
mov ax, cs
mov ds, ax
old_key DD 00000000h
MOV AL, 9h ;+-
MOV AH, 35h ;| Save old_key
INT 21h ;|
MOV WORD PTR [old_key],BX
MOV WORD PTR [old_key][2],ES
; cli
; PUSH CS ;| Install new_key
; POP DS ;|
; LEA DX, new_key
; MOV AL, 9h
; MOV AH, 25h
; INT 21h
cli
push ds
LDS DX,CS:[old_key] ;+-
MOV AL, 9h ;| Disinstall new_key
MOV AH, 25h ;|
INT 21h
POP DS
STI
mov ax, TSR
int CALLDOS
end start
由于即使在注释掉安装后仍然存在问题,我认为问题出在卸载或保存old_key上.我不知道哪里出了问题.应该不是安装和卸载代码与计时器中断的安装/卸载代码本质上相似?
Since there are problems even when I've commented out the installation, I think the problem lies with the disinstallation or the old_key saving. I do not know what is wrong however; shouldn't the installation and disinstallation code be essentially similar timer interrupt's install/disinstall code?
我们将不胜感激,谢谢您.
Assistance would be appreciated, thank you in advance.
推荐答案
mov ds, ax
old_key DD 00000000h
MOV AL, 9h ;+-
您不应该这样混合代码和数据. CPU不知道old_key
不是代码,因此它将很乐意尝试执行它.将变量移到setup
标签之前,或插入跳转指令以跳过该变量.
You shouldn't mix code and data like that. The CPU has no knowledge of old_key
not being code, so it will happily try to execute it. Either move the variable to before the setup
label, or insert a jump instruction to skip past it.
这篇关于需要帮助,在MS-DOS中钩新的键盘中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!