a real mode MS-DOS qestion

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
VoidLogic

a real mode MS-DOS qestion

Post by VoidLogic »

I need to figure out how to make some TSR progrrams unloadable, I'm a rather good C/C++ programer with minimal asm know-how.
Thanks

VoidLogic
Chase

RE:a real mode MS-DOS qestion

Post by Chase »

Do TSRs work basically like BIOS services? When you write a BIOS service you're loading a little program into memory and setting a int vector to point to your program. If you just have your service save the original int vector that way you can restore it.....
Khumba

RE:a real mode MS-DOS qestion

Post by Khumba »

A TSR is a normal DOS program, except it exits by calling a different INT 21 routine that leaves it in memory. For it to work you need to tie into INT 9 (if it's a keyboard handler), or whatever interrupt you need.

If you want to disable interrupts, you can try to tie into INT 21, just return if the exit-to-TSR routine is called or pass the call on to the original INT 21 if it's ok. I'm not sure if DOS will automatically reset INT 21, though.
VoidLogic

RE:a real mode MS-DOS qestion

Post by VoidLogic »

my TSRs basicaly act as runtime librarys so that exes can make function calls to them via pointers. _dos_keep(0, (_SS + (_SP/16) - _psp)); makes the exe a TSR, how would i unload it?

Thanks
-VoidLogic
eox

RE:a real mode MS-DOS qestion

Post by eox »

it's possible to unload it.. iirc there was a special exit function on int 0x21 or some other dos functions to free up your memory.

can't look it up at the moment, the book in which there's an example how it works is at home and i'm far away from there.. perhaps i can look it up on friday
eox

RE:a real mode MS-DOS qestion

Post by eox »

to unload your tsr you have to reset your interrupt vectors to their original values and free the mem your tsr occupies.

you can do that using

on tsr init you have to save es:
mov  psp,es

;mov  es, the seg addr of the memblock you want to free
mov  es,psp
mov  ah,49h  ; dos function: free mem
int  21h


i think that should work (hey, it's long time ago since i coded some things in dos...;)
VoidLogic

RE:a real mode MS-DOS qestion

Post by VoidLogic »

Cool! Thanx a ton.
Now I just  need to firgure out how to use this ASM in relation to my C\C++ program.

*VoidLogic
Post Reply