If your program is running under DOS, you can (and probably should) use the API provided by DOS:
MOV AH,35H ; function 35H is Get Vector
MOV Al,9 ; slot in IDT for keyboard interrupt
INT 21H ; call DOS, contents of old vector in ES:BX (save them somewhere)
.
.
MOV AH,25H ; function 25H is Set Vector
MOV AL,9
PUSH CS ; the new vector is passed in DS:DX, so copy CS to DS
POP DS : (assuming your new handler is in the same seg as other code)
MOV DX,NewHandler
INT 21H
source
share