Search code examples
assemblydostsr

Assembly TSR(Terminate-Stay-Resident) on interupt 9h


I created program that changes basic INT 9h in assembly with my own routine called "tastatura".

_inst_09:

cli
xor     ax, ax
mov     es, ax
mov     bx, [es:09h*4]
mov     [stari_int09_off], bx 
mov     bx, [es:09h*4+2]
mov     [stari_int09_seg], bx

mov     dx, tastatura
mov     [es:09h*4], dx
mov     ax, cs
mov     [es:09h*4+2], ax
sti
ret

The thing i want to do is to make this program resident. What i mean is that when my program is finished i still want INT 9h to point at my routine.
I know that i need to use mov ah,31h and int 21h to create TSR but i dont know where to put it.
It would be good if u give me an actual answer rather than some links and tutorials because i read them all, and read all books and i still could not figure it out.
If you need whole code i can edit post and put it on.
Thanks in advance.


Solution

  • After sti, you invoke function 31h of the interrupt 21h:

    mov ax, 3100h ; function 31h in AH, exit code 0 in AL
    mov dx, 17 ; memory size to keep; 16 for PSP alone
    int 21h
    

    That's it. Your program terminates but stays in memory. The line after int 21h will not execute.