qa.hlp (Table of Contents; Topic list)
Vector
   Example  Back  Contents  Index
──────────────────────────────────────────────────────────────────────────────
 
;* Vector - Macro to read current interrupt vector, store it, and replace it.
;*
;* Shows:   Equates - @CodeSize     @code
;*
;* Params:  num - Vector number
;*          old - Pointer to doubleword for storing old vector
;*          new - Pointer to new handler
 
Vector MACRO num, old, new              ;; Macro definition
    push ds                             ;; Save DS and ES registers
    push es
    mov ah, 35h                         ;; AH = DOS function number
    mov al, num                         ;; AL = interrupt number
    int 21h                             ;; Get Interrupt Vector
    mov WORD PTR old[0], bx             ;; Store it
    mov WORD PTR old[2], es
    IF @CodeSize                        ;; If medium or large model,
        lds dx, new                     ;;    load DS from parameter
    ELSE
        mov bx, @code                   ;; Else ensure DS points to
        mov ds, bx                      ;;    to code segment
        mov dx, new                     ;; DS:DX equals new vector
    ENDIF
    mov ah, 25h                         ;; AH = DOS function number
    int 21h                             ;; Set Interrupt Vector
    pop es                              ;; Restore ES and DS
    pop ds
ENDM
                                    -♦-