-1

我在 nasm 中创建了一个 tsr 程序。它工作正常,但当我按下“ESC”按钮时,我还必须其从内存中删除并将所有挂钩的中断恢复为原始状态。这是我按下“ESC”按钮时运行的代码的一部分。

uninst:
cli
xor ax, ax
mov es, ax
mov ax, [stari_int09_seg]
mov [es:09h*4+2], ax
mov dx, [stari_int09_off]
mov [es:09h*4], dx
sti
mov ah,49h
int 21h
iret

所以我恢复了我更改为原始值的 int 09h 并用 清除了我的内存mov ah,49h
,但是当我按下“ESC”时,我的 dos 控制台变得无响应。这意味着我没有以正确的方式删除我的 TSR。我的第一个问题是我错过了什么吗?是否有任何有 TSR 计划经验的人可以真正给出适当的答案。

4

2 回答 2

0

我们必须将要释放的块段放入 ES 段寄存器中。

RBIL->inter61b.zip->INTERRUP.G
--------D-2149-------------------------------
INT 21 - DOS 2+ - FREE MEMORY
AH = 49h
ES = segment of block to free
Return: CF clear if successful
CF set on error
    AX = error code (07h,09h) (see #01680 at AH=59h/BX=0000h)
Notes:  apparently never returns an error 07h, despite official docs; DOS 2.1+
  code contains only an error 09h exit
DOS 2.1-6.0 does not coalesce adjacent free blocks when a block is
  freed, only when a block is allocated or resized
the code for this function is identical in DOS 2.1-6.0 except for
  calls to start/end a critical section in DOS 3.0+
SeeAlso: AH=48h,AH=4Ah
于 2014-11-07T07:24:17.893 回答
0

您确定 DS 指向您存储向量 9 原始值的段吗?
正如其他人指出的那样,您需要在调用 DOS 函数 49h 之前设置 ES。
释放内存后立即执行 IRET。我会期待一堆 POP 指令,因为这段代码是中断例程的一部分,因此不能更改任何寄存器!

于 2014-11-09T21:26:46.923 回答