How to keep resident only a part of the program (Developers)
> Hello Laaca,
>
> > I am thinking about very tiny resident utility which hooks the INT16
> > interrupt. I know that "high-level" languages like pascal or C have
> > something like function Keep (which apparently calls INT21h/AH=31h). But
>
> Actually the int 0x21, ah = 0x31 interface does allow one to specify how
> many paragraphs of memory one wants to keep resident. Turbo C and Watcom C
> also accept a paragraph count as a parameter to keep(...) and
> (respectively) _dos_keep(...).
>
> But it might be hard to use this correctly in the context of high-level
> code. You need to arrange your program binary code in such a way that the
> resident portions will come before (most of) the transient portions (and
> you must take library functions into account too...). I am not sure what
> features Free Pascal (e.g.) has that might facilitate this sort of thing.
>
> > Is possible solution to allocate a additional memory block via
> > INT21h/AH=48h, copy the code of KeyClick into this block and the program
> > end not with Keep but hith Halt?
>
> That will likely not work --- DOS will free up all memory blocks
> allocated by your program, including those from int 0x21, ah = 0x48.
while true (this wouldn't work), you can make it work by using the undocumented feature that DOS_realloc(para, size) also sets the PSP of the allocated memory, and on exit(), DOS will only free allocated memory with your PSP.
so a sequence like
needed_bytes = 1024;
resident_seg = DOS_alloc(needed_bytes);
my_PSP = DOS_GET_PSP();
DOS_SET_PSP(0x60); program 0x60 will never exit
DOS_realloc(resident_seg, needed_bytes);
DOS_SET_PSP(my_PSP);
memcpy(MK_FP(resident_seg,0), my code, needed_bytes);
point interrupt vector to the copied code
...
exit()
would work in principle (remove the large program from memory, leave needed_bytes in memory).
of course, your code would really quickly implode because you are calling the runtime library (sound(), delay()) and you have little to no control over where the runtime will be loaded.
time to change the language
Pascal is just not the right language for this kind of stuff.
Complete thread:
- How to keep resident only a part of the program - Laaca, 14.08.2021, 07:31 (Developers)
- How to keep resident only a part of the program - tkchia, 14.08.2021, 08:49
- How to keep resident only a part of the program - Laaca, 14.08.2021, 10:32
- How to keep resident only a part of the program - tom, 14.08.2021, 11:40
- How to keep resident only a part of the program - RayeR, 14.08.2021, 15:49
- How to keep resident only a part of the program - Laaca, 14.08.2021, 20:18
- How to keep resident only a part of the program - RayeR, 16.08.2021, 03:22
- How to keep resident only a part of the program - Laaca, 14.08.2021, 20:18
- How to keep resident only a part of the program - RayeR, 14.08.2021, 15:49
- How to keep resident only a part of the program - tom, 14.08.2021, 11:40
- How to keep resident only a part of the program - tom, 14.08.2021, 11:28
- How to keep resident only a part of the program - ecm, 15.08.2021, 13:47
- How to keep resident only a part of the program - bretjohn, 27.08.2021, 21:22
- How to keep resident only a part of the program - Laaca, 14.08.2021, 10:32
- How to keep resident only a part of the program - marcov, 14.08.2021, 13:18
- How to keep resident only a part of the program - CandyMan, 27.08.2021, 17:46
- How to keep resident only a part of the program - bretjohn, 27.08.2021, 21:47
- How to keep resident only a part of the program - Laaca, 08.03.2022, 12:24
- How to keep resident only a part of the program - tom, 08.03.2022, 12:51
- How to keep resident only a part of the program - tkchia, 08.03.2022, 14:20
- How to keep resident only a part of the program - bretjohn, 08.03.2022, 19:19
- How to keep resident only a part of the program - tkchia, 08.03.2022, 14:20
- How to keep resident only a part of the program - rr, 08.03.2022, 17:32
- How to keep resident only a part of the program - tom, 08.03.2022, 12:51
- How to keep resident only a part of the program - tkchia, 14.08.2021, 08:49