DOS TSR program in upper memory
Posted: 08 Sep 2023 20:03
On 2023/09/08 ecm says at Stack Overflow:
When Action I: Install TSR to upper memory was selected. in the code Main.I: indeed says
I am not sure now why I chose to allocate this much upper memory, perhaps my DOS 5 refused to terminate and left resident the incomplete PSP in those times (30 years ago).
Nevertheless, tsrup.com /I works in DosBox and only shortened PSP + resident is finally allocated in the upper memory (9 paragraphs = 144 bytes).
If you are developping TSR for the real DOS, you can try calling AllocUMB with
Anyway, thank you for checking.
Code: Select all
In your tsrup example, it is said that a UMB must be allocated OFFSET# TsrTop - Shift bytes. However, the AllocUMB function is called with MOV CX,OFFSET# TsrTop / 16 so it appears to allocate too much. Is this an oversight in your example, or am I mistaken? –
MOV CX,OFFSET# TsrTop / 16 ; Number of paragraphs for the resident code. CALL AllocUMBAllocUMB is called here with CX=0x13, i.e. 304 bytes which covers the entire PSP + the size of resident code.
I am not sure now why I chose to allocate this much upper memory, perhaps my DOS 5 refused to terminate and left resident the incomplete PSP in those times (30 years ago).
Nevertheless, tsrup.com /I works in DosBox and only shortened PSP + resident is finally allocated in the upper memory (9 paragraphs = 144 bytes).
>mem /c Modules using memory below 1 MB: Name Total Conventional Uppper Memory -------- ---------------- ---------------- ---------------- SYSTEM 28,720 (28K) 28,720 (28K) 0 (0K) COMMAND 3,216 (3K) 3.216 (3K) 0 (0K) tsrup 144 (0K) 0 (0K) 144 (0K) Free 703,952 (687K) 622,176 (608K) 81,776 (80K)
If you are developping TSR for the real DOS, you can try calling AllocUMB with
CX=(OFFSET# TsrTop - Shift) / 16 ; Number of paragraphs for the resident code.I might try it myself in future release, but I don't promise for sure. Memory allocation is not easy to debug in DosBox and TSR programs are not in my concern nowadays, sorry.
Anyway, thank you for checking.