home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / ibm / pc / hardware / 23151 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  2.9 KB

  1. Xref: sparky comp.sys.ibm.pc.hardware:23151 comp.sys.ibm.pc.programmer:361
  2. Newsgroups: comp.sys.ibm.pc.hardware,comp.sys.ibm.pc.programmer
  3. Path: sparky!uunet!caen!hellgate.utah.edu!fcom.cc.utah.edu!news
  4. From: alex@fff.chem.utah.edu (Alex Dommasch)
  5. Subject: Re: Saving the state of the 80x87 math co-pro - SUMMARY
  6. Message-ID: <1992Sep1.164837.27951@fcom.cc.utah.edu>
  7. Sender: news@fcom.cc.utah.edu
  8. Organization: University of Utah Computer Center
  9. References: <1992Aug24.220638.25002@fcom.cc.utah.edu>
  10. Date: Tue, 1 Sep 92 16:48:37 GMT
  11. Lines: 56
  12.  
  13. In article <1992Aug24.220638.25002@fcom.cc.utah.edu> alex@fff.chem.utah.edu  
  14. (Alex Dommasch) writes:
  15. > I am using an interrupt routine to do data aquisition while other processing  
  16. is  
  17. > going on.  However, both the main routine and the interrupt routine need to  
  18. use  
  19. > floating point operations - hence, the interrupt routine often steps on any  
  20. > calculations in progress in the main routine.  I figured out that I have to  
  21. > save the state of the 8087 on entry, and restore it on exit.  However, I have  
  22. > absolutely no idea how to do this.
  23. > I am using Turbo C 2.0.  This program has to run on XT's, AT's and 386's,  
  24. both  
  25. > with and without coprocessors (so I have to figure out how to save the state  
  26. of  
  27. > the emulation library as well).  I am at a total loss at how to do this.  Any  
  28. > help would be greatly appreciated.
  29.  
  30. Kevin Kraul was kind enough to send me a solution to this problem *if* you are  
  31. using a math coprocessor (Thanks Kevin; hope you don't mind me posting this):
  32. ----------------------------
  33.  static void interrupt InterruptHandler(void)
  34.     {
  35.        char     coprocessor_state[94];
  36.              .
  37.              .  // Insert other declarations here.
  38.              .
  39.  
  40.        // Note: interrupts are disabled by the processor (80X86) automatically.
  41.        asm fsave coprocessor_state;   // Save floating point state and regs.
  42.        enable();   // Enable interrupts so other interrupts can be processed.
  43.  
  44.             .
  45.             .  // Insert your code here!
  46.             .
  47.  
  48.        asm frstor coprocessor_state;  // Restore the coprocessor state.
  49.     }
  50. ----------------------------
  51.  
  52. However, this does not work when you are using emulation on machines without a  
  53. co-pro.  Apparently this is a much more difficult problem.  If any one has a  
  54. simple solution to it, I'd be glad to hear about it.
  55.  
  56. It seems to me, however, that Borland should have put instructions to do this  
  57. in their library.  I mean, they went to all the trouble to make a special  
  58. interrupt function type, why couldn't they have taken the last step and saved  
  59. the floating-point state?
  60. --
  61. Alex Dommasch, Programmer                       |--   
  62. Field-Flow Fractionation Research Center        |-    
  63. Department of Chemistry, University of Utah     V     
  64. Salt Lake City, Utah 84112                      |->|..
  65. (801)581-7168           FAX: (801)581-4353      |- |. 
  66. alex@fff.chem.utah.edu (NeXT Mail)              |  |  
  67.