home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!uc.msc.edu!apctrc!drd!walt
- From: walt@drd.com (Walt.Gaber)
- Subject: DLL - floating point return values?
- Message-ID: <1992Dec16.141711.5110@drd.com>
- Organization: DRD Corporation
- Date: Wed, 16 Dec 1992 14:17:11 GMT
- Lines: 55
-
-
- I have been unsuccessful in writing a DLL function that returns either a
- float or a double. I cannot find anything in the documentation I've got
- (including the MS Developer Network CDROM) that discusses problems or
- solutions for doing this. I have tried several memory model and floating
- point (/FP_) options.
-
- I have tried to determine what is happening via CodeView. I believe that
- floating point return values are placed at some address for retrieval by the
- calling code (unlike integer returns which are conveyed via AX {and DX} if
- necessary). Does the DS!=SS behavior come into play here?
-
- In the calling function:
- SS = 1197
- DS = 1197
-
- In the DLL function:
- SS = 1197
- DS = 1D67
-
- In the DLL function , the following code is executed (immediately before the
- return):
- FLD DWORD PTR [BP-08]
- INT 3D ;fwait
- MOV BX,WORD PTR [BP+06]
- NOP
- FSTP DWORD PTR [BX]
- INT 3D ;fwait
- MOV AX,WORD PTR [BP+06]
- MOV DX,SS
- POP DI
- POP SI
- LEA SP,WORD PTR [BP-02]
- POP DS
- POP BP
- DEC BP
- RETF 0006
-
- Upon return from the function, the following code is executed:
- MOV BX,AX
- MOV AX,WORD PTR [BX]
- MOV DX,WORD PTR [BX+02]
- MOV WORD PTR [BP-011C],AX
- MOV WORD PTR [BP-011A],DX
-
-
- If I manually and temporlarly change (within the debugger) the DS register
- to use the DS of the DLL, I can successfully retrieve the stored value.
-
- Is there some way that I can force the DLL to place the value in an
- accessible location and coerce the calling code to locate it?
-
- ---
- walt.gaber@drd.com (918) 743-3013
- DRD Corp., 5506 South Lewis Ave., Tulsa, OK 74105 (918) 745-9037 fax
-