0

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.

Bozic
  • 159
  • 1
  • 12

1 Answers1

2

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.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • Doesn't DOS use the value of `dx` (number of paragraphs to keep resident) when you TSR to update the amount of free conventional memory? – Michael Oct 31 '14 at 17:30
  • I have a little problem. When my program terminates i cannot type anything. Its like the screen is frozen – Bozic Oct 31 '14 at 22:38
  • That's an unrelated problem; please accept this one and ask a new question. Most likely, your int 9 interrupt handler is wrong. Are you invoking the original handler first thing? – Seva Alekseyev Nov 01 '14 at 01:28