bluelbo@ucscb.ucsc.edu (Blue Elbow) (08/17/90)
Topic: Turbo Pascal 5.5 Overlays AND Turbo C++ 1.0 Overlays ---at the same time!---- I am writing a word processor in Pascal, and have a spell checker written in C. The two are successfully integrated but not with overlays. Problem: I don't use the stacks properly so the Pascal overlay manager crashes while 'walking' the stack. Solution: Use the stack properly. But to do this, I need to know EXACTLY what the overlay manager expects to see on the stack. My view: Stack (size is 16K bytes) SS:4000 Bottom of Stack ------------ 3ffe 0000 bottom 3ffc 0000 ------------ 3ffa -BP- original BP 3ff8 -pushed call proc_1 3xxx parameters- 3xxx -return (program) 3xxx address- ------------ 3xxx 3ff8 (BP) previous BP xxxx -local xxxx variables- xxxx -pushed call proc_2 xxxx parameters- xxxx -return (proc_1) xxxx address- ----------- xxxx -BP- previous BP xxxx etc OK, the BP stack frame is a _MUST_ for the overlay manager. Fine. But the spell checker is an external program (CSPELL.EXE) which requires a DOS.Exec() call. Once the exec gives control to CSPELL, Pascal is dormant and C has its own seperate stack. Now the trouble becomes obvious. The word processor must regain control for displaying prompt windows, updating the screen, submitting words for spell verification, etc. Pascal must regain control of its stack and put it in a form recognizable by its overlay manager. xxxx -return (my.spellchk) xxxx address- ------------- xxxx -BP- previous BP xxxx -EXEC call DOS xxxx parameters- xxxx -return (my.invoke) xxxx address- ------------- xxxx -BP- previous BP xxxx -EXEC local xxxx variables- xxxx -FLAGS- int 21h xxxx -return (DOS.Exec) xxxx address- ------------ xxxx ??????????? Does int 21h use any of my local Pascal stack? Or if I figure out where the next free space in the stack is, can I just use it? Will the overlay manager look at the -return address- to DOS.Exec and know what it is? How can I verify what I am doing is correct? Side notes for those wondering: The C program creates its own stack, much like the pascal code has its own. Communication between the two is initiated by a parameter on the command tail (line) passed to CSPELL.EXE, for example CSPELL 1234ABCD87 which says that a data structure is located at physical memory 1234:ABCD, with checksum 8 and not checksum 7. Once the address is verified with the checksum, CSPELL's main() sets a struct pointer to that address, stores where the C stack, BP, SP, and pointers to important C spell functions are, and does a far call to the Pascal code via an address (supplied by the Pascal code) in the structure. The pascal code's job is now the user interface of the spell checking, and does far calls back to the C code for spelling verification, correction, and additions to a personal dictionary. Once completed, the Pascal does a far return (RETF, opposite of far call) to return to the C code, which terminates the spell checker and then main() does a return(0) which ends the exec() call. Thus the C program has terminated and only the Pascal code is in memory. (I have taken care of heap problems in Pascal by moving down the free list and limiting the heap to 8K... hopefully not that much required by spelling corrections, etc.) Now if that didn't confuse you completely, and you have a useful, intelligent answer, or worthwhile input, please respond. I am requesting this help of utmost urgency. Thanks! - Dave (Blue Elbow) -- David R. Van Wagner bluelbo@ucscb.ucsc.edu P.O. Box 211 ...!ucbvax!ucscc!ucscb!bluelbo Mount Hermon, CA 95041 work: (408) 459-8811 USA (408) 335-7578 FAX: (408) 459-8853