大会DOS(TASM),对INT 21H一个新的处理程序创建TSR [英] Assembly on DOS (TASM), creating TSR with a new handler on int 21h

查看:231
本文介绍了大会DOS(TASM),对INT 21H一个新的处理程序创建TSR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有做TSR COM文件为DOS麻烦。它应该设置一个新的处理程序上21'th中断,终止和驻留。新的处理程序应该控制转移到旧的中断处理程序21H。我保存它的中断向量,但不知道如何正确地调用它。下面是一个程序:

  .MODEL微小
。数据
    old_int21h DW?,?
。code
组织100H
开始:    ;保存旧中断向量
    MOV AX,3521h
    INT 21H
    MOV [old_int21h],BX
    MOV [old_int21h + 2],ES    ;设定新的中断向量
    CLI
    推DS
    推CS
    流行DS
    LEA DX,myint21h
    MOV AX,2521h
    INT 21H
    流行DS
    STI    ; TSR
    LEA DX,开始
    INT 27Hmyint21h PROC
    ;做什么
    ;要控制这里转移到旧的中断处理程序21H。怎么样?
    IRET
myint21h ENDP年底启动


解决方案

我明白这个问题。正确的解决办法是在这里。 右是不能肯定最佳,但无论如何作品很好,这是不是够硬,现在来优化这个code。

  .MODEL微小
。code
组织100H
开始:    ;节约旧中断向量
    MOV AX,3521h
    INT 21H
    MOV [old_int21h],BX
    MOV [old_int21h + 2],ES    ;设置新的中断向量
    CLI
    推DS
    推CS
    流行DS
    LEA DX,myint21h
    MOV AX,2521h
    INT 21H
    流行DS
    STI    ; TSR
    MOV DX,00FFH
    MOV AX,3100H
    INT 21H    ;这里来的数据和放大器; HEW处理部分
    old_int21h DW?,?    myint21h PROC
                    ;一些东西
                    ;控制转移到旧的中断处理程序21H
        推字PTR [CS:old_int21h + 2];分割
        推字PTR [CS:old_int21h];抵消
        RETF
    myint21h ENDP年底启动

下面的答案是差不多吧:)

I have a trouble with making TSR com file for DOS. It should set a new handler on a 21'th interrupt, terminate and stay resident. New handler should transfer control to an old interrupt 21h handler. I save its interrupt vector, but have no idea how to call it correctly. Here is a program:

.model tiny
.data
    old_int21h dw ?, ?
.code
org 100h
start:

    ;saving old interrupt vector
    mov ax, 3521h
    int 21h
    mov [old_int21h], bx
    mov [old_int21h + 2], es

    ;setting new interrupt vector
    cli
    push ds
    push cs
    pop ds
    lea dx, myint21h
    mov ax, 2521h
    int 21h
    pop ds
    sti

    ; TSR
    lea dx, start
    int 27h

myint21h proc
    ; doing something
    ; want to transfer control to an old interrupt 21h handler here. How?
    iret
myint21h endp

end start

解决方案

I understood the problem. The right solution is here. "Right" isn't sure "optimal", but works nice anyway, and it isn't hard enough to optimize this code now.

.model tiny
.code
org 100h
start:

    ; saving old interrupt vector
    mov ax, 3521h
    int 21h
    mov [old_int21h], bx
    mov [old_int21h + 2], es

    ; setting new interrupt vector
    cli
    push ds
    push cs
    pop ds
    lea dx, myint21h
    mov ax, 2521h
    int 21h
    pop ds
    sti

    ; TSR
    mov dx, 00ffh
    mov ax, 3100h
    int 21h

    ; here comes data & hew handler part
    old_int21h dw ?, ?

    myint21h proc
                    ; some stuff
                    ; transfer control to an old interrupt 21h handler
        push word ptr [cs:old_int21h + 2] ; segment
        push word ptr [cs:old_int21h]     ; offset
        retf
    myint21h endp

end start

The answer below was almost right :)

这篇关于大会DOS(TASM),对INT 21H一个新的处理程序创建TSR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆