home *** CD-ROM | disk | FTP | other *** search
- A special note for BC++ 2.0 users.
-
- I encountered some difficulties using this PrintBGI package in huge
- memory model with BC++ 2.0. The program behaved very strangely in some
- rare but unpredictable situations. After few days of debugging sessions I
- narrowed the problem but couldn't eliminate it. So what happens?
-
- The problem is strongly related to coprocessor emulation.
- Since I don't have sources of Borland's coprocessor emulation
- routines all what I'm writing here is only my speculation
- and may be not necessarily the truth.
-
- The coprocessor emulation routines use some space for saving their
- variables and to emulate the stack of coprocessor. Since in huge memory
- model all user or library functions use DS register for their own purposes
- the emulator must either save it, use as it wants and restore or set ES
- register and use it to access it's working space. Isn't this right? It isn't.
- It uses the third method. Addresses it's working space using SS register.
- Simply it uses the bottom of the stack. The start of the stack has even
- an external label called _emu. I will refer to emulation working space as
- a _emu variable.
-
- Now let's look at the Turbo debugger CPU window. After we execute
- Go to e086_Entry command we may see something like that
- xxxx:xxxx e086_Entry: sti
- cld
- push AX
- .... some other push statements
- mov BP,SP
- mov SS:[032h],BP
- .... other code
- Let's look at the statement mov SS:[032h],BP. In this statement emulator
- saves BP register in it's working space. But not in the code of my BGIDEMO
- generated for huge model by BC++ 2.0. In that case instead of mov
- SS:[032h],BP
- you may see mov SS:[1EC2h],BP.
- Why it happens?
- It seems that linker resolves all references to _emu variable assuming
- it is in the data segment not in the stack segment. Maybe it finds somewhere
- a GROUP directive grouping Start up data segment and the stack together?
-
- So I get wrong results from linking process and have no idea how can I
- correct it. It is not simply a bug in BC++ 2.0 since all small testing
- programs I wrote were linked correct.
- Note also that there is only one version of emulation library used for
- all memory model. It links O.K. in large model (independently of compiler
- version) with my program. It also links O.K. in BC++ 3.0. The only one wrong
- case is huge model, BC++ 2.0 (I have no idea about earlier compilers), and
- my program. I even compiled it entirely in huge memory model and the results
- were the same. I suppose the problem is related with GROUP concepts.
- But I don't use GROUP directive explicitly in any of my modules.
- So I assume it is in one of standard LIB files but I'm not sure about it.
-
- I'm not so experienced with PC's to know what to do. If you have any ideas
- which may help let me know of them.
- Thanks.
-