iiit-sh@cybaswan.UUCP (Steve Hosgood) (07/05/89)
The Program Segment Prefix (PSP) of a normal DOS command is the 100h bytes before the start of the code proper, and contains: 00-5B: Reserved stuff 5C-6B: Default FCB #1 6C-7B: Default FCB #2 80-FF: Command Tail and default DTA. 100: Start of program area The rules for normal processes state "do *not* alter the area below 5Ch". I am given to understand that the area below 5Ch is used by DOS to keep track of processes in memory, and to remove them when they complete. Now the Question: Can the resident part of a TSR get away with using the area below 5Ch? I would *think* that DOS has no further use for the PSP after the program becomes resident, but of course the area may still figure in some sort of linked-list internally in DOS. Any info please? I'll summarise any email I get to the net. Steve -----------------------------------------------+------------------------------ Steve Hosgood BSc, | Phone (+44) 792 295213 Image Processing and Systems Engineer, | Fax (+44) 792 295532 Institute for Industrial Information Techology,| Telex 48149 Innovation Centre, University of Wales, +------+ JANET: iiit-sh@uk.ac.swan.pyr Swansea SA2 8PP | UUCP: ..!ukc!cybaswan.UUCP!iiit-sh ----------------------------------------+------------------------------------- My views are not necessarily those of my employers! -- -----------------------------------------------+------------------------------ Steve Hosgood BSc, | Phone (+44) 792 295213 Image Processing and Systems Engineer, | Fax (+44) 792 295532 Institute for Industrial Information Techology,| Telex 48149
maa@nbires.nbi.com (Mark Armbrust) (07/15/89)
In article <536@cybaswan.UUCP> iiit-sh@cybaswan.UUCP (Steve Hosgood) writes: > >Now the Question: Can the resident part of a TSR get away with using the area >below 5Ch? I would *think* that DOS has no further use for the PSP after the >program becomes resident, but of course the area may still figure >in some sort of linked-list internally in DOS. The first 5Ch bytes of the PSP are called the Process Data Block (PDB). The information in the PDB is used during program execution as well as program spawn and termination. The format of the DOS 3.3 PDB is: OFFSET SIZE CONTENTS ------ ---- -------- 00h 2 INT 20h instruction. 02h 2 Size of the process in paragraphs when it was started 04h 1 unused 05h 5 Far call to DOS -- Ancient CPM compatible OS call 0Ah 4 Far pointer to exit routine, normally points to instruction after spawn call in parent process. 0Eh 4 Far pointer to ^C interrupt routine. 12h 4 Far pointer to fatal error routine, normally points to code that gives you the "ABORT, RETRY, IGNORE?" message. 16h 2 Process ID (PID) of parent process 18h 20t Job File Number (JFN) table -- used to process's file handle into system file handles 2Ch 2 Segment address of process's environment variables 2Eh 4 Process stack pointer save area during system calls 32h 2 JFN table size 34h 4 Far pointer to JFN -- normally points to JFN table in PDB, but can be changed if the JFN table needs to be bigger. 38h 4 Pointer to next PDB in list -- I've never seen this to be any- thing other than 0FFFF:0FFFFh 3Ch 14h unused 50h 5 INT 21h; RETF; 0; 0 -- "Portable DOS call" interface 55h 7 unused As you can see, when a TSR is running on it's own PID (as it has to to do file operations), there are several things in the PDB that are still required. Hope this helps. -- Mark Armbrust maa@nbires.nbi.com maa@nbires.UUCP
dulimart@cpsvax.cps.msu.edu (Hansye S. Dulimarta) (07/19/89)
In article <536@cybaswan.UUCP> iiit-sh@cybaswan.UUCP (Steve Hosgood) writes: >[deleted stuff...] >Now the Question: Can the resident part of a TSR get away with using the area >below 5Ch? I would *think* that DOS has no further use for the PSP after the >program becomes resident, but of course the area may still figure >in some sort of linked-list internally in DOS. > >Steve Once you hooked up your TSR routine to any interrupt handler, the PSP is not used anymore. BTW, I knew a TSR routine which used its PSP to store the old vector interrupt address it handles. Also remeber the way we put our routine into TSR, by calling DOS call (int 21h function 31h or by int 27h), in these calls we have to specify the address which we want to be resident in memory. The PSP is below this address, but of course our interrupt handler's entry point is not exactly at the PSP, instead the entry point is somewhere _after_ the PSP. Hope it helps. Hans.
andrews@hpcupt1.HP.COM (Edward E. Andrews) (07/20/89)
Your TSR should use it's own PSP if: 1) You want to use your own ^C handler, 2) You want to use your own critical error handler, or 3) You want to do file I/O with handles. 4) You want to do any DOS functions (i.e. INT 21h) To get the current PSP: mov ah,51h int 21h mov OldPSP,bx To set the current PSP: mov ah,50h mov bx,NewPSP int 21h Enjoy!
don@trsvax.UUCP (07/20/89)
>>Now the Question: Can the resident part of a TSR get away with using the area >>below 5Ch? I would *think* that DOS has no further use for the PSP after the >>program becomes resident, but of course the area may still figure >>in some sort of linked-list internally in DOS. >Once you hooked up your TSR routine to any interrupt handler, the PSP is not >used anymore. This is not in general correct. It may be correct for some TSR's, but if a TSR performs any interrupt 21h functions (after checking for re-entrancy, of course), some values in the current PSP are altered, so you need to set up your PSP as the current PSP before performing such operations. The same goes for disk I/O. At any rate, a TSR's PSP may be used after the program has gone resident, so you need to make sure it isn't used before you re-use it. BTW, sometimes I move the stack pointer to 100h in a com file so the stack grows over the PSP. If I need more stack, I can make my first statement as a jump, then allocate a data buffer immediately after that point, setting up the stack to point at the end of my new buffer. I assume by the time the stack has grown over my first statement, I've already executed it. --------------------------------------------------------------------- I purchase Product 19 because it's the only cereal I know named after a prime number. - paraphrased from a posting in rec.humor.funny Don Subt The opinions expressed above are Tandy Corp. strictly mine, not my employer's. 817-390-3068 ...!killer!ninja!sys1!trsvax!don