home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4275 < prev    next >
Encoding:
Text File  |  1992-12-16  |  2.0 KB  |  65 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!noc.msc.net!uc.msc.edu!apctrc!drd!walt
  3. From: walt@drd.com (Walt.Gaber)
  4. Subject: DLL - floating point return values?
  5. Message-ID: <1992Dec16.141711.5110@drd.com>
  6. Organization: DRD Corporation
  7. Date: Wed, 16 Dec 1992 14:17:11 GMT
  8. Lines: 55
  9.  
  10.  
  11. I have been unsuccessful in writing a DLL function that returns either a
  12. float or a double.  I cannot find anything in the documentation I've got
  13. (including the MS Developer Network CDROM) that discusses problems or
  14. solutions for doing this.  I have tried several memory model and floating
  15. point (/FP_) options.
  16.  
  17. I have tried to determine what is happening via CodeView.  I believe that
  18. floating point return values are placed at some address for retrieval by the
  19. calling code (unlike integer returns which are conveyed via AX {and DX} if
  20. necessary).  Does the DS!=SS behavior come into play here?
  21.  
  22. In the calling function:
  23.      SS = 1197
  24.      DS = 1197
  25.  
  26. In the DLL function:
  27.      SS = 1197
  28.      DS = 1D67
  29.  
  30. In the DLL function , the following code is executed (immediately before the
  31. return):
  32.     FLD DWORD PTR [BP-08]
  33.     INT    3D ;fwait
  34.     MOV    BX,WORD PTR [BP+06]
  35.     NOP
  36.     FSTP   DWORD PTR [BX]
  37.     INT    3D ;fwait
  38.     MOV    AX,WORD PTR [BP+06]
  39.     MOV    DX,SS
  40.     POP    DI
  41.     POP    SI
  42.     LEA    SP,WORD PTR [BP-02]
  43.     POP    DS
  44.     POP    BP
  45.     DEC    BP
  46.     RETF   0006
  47.  
  48. Upon return from the function, the following code is executed:
  49.     MOV    BX,AX
  50.     MOV    AX,WORD PTR [BX]
  51.     MOV    DX,WORD PTR [BX+02]
  52.     MOV    WORD PTR [BP-011C],AX
  53.     MOV    WORD PTR [BP-011A],DX
  54.  
  55.  
  56. If I manually and temporlarly change (within the debugger) the DS register
  57. to use the DS of the DLL, I can successfully retrieve the stored value.
  58.  
  59. Is there some way that I can force the DLL to place the value in an
  60. accessible location and coerce the calling code to locate it?
  61.  
  62. ---
  63.    walt.gaber@drd.com                                       (918) 743-3013
  64.    DRD Corp., 5506 South Lewis Ave., Tulsa, OK 74105        (918) 745-9037 fax
  65.