cpu.pp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,98 by Florian Klaempfl,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { this unit contains some routines to get informations about the
  13. processor
  14. }
  15. unit cpu;
  16. {$I386_INTEL}
  17. interface
  18. { returns true, if the processor supports the cpuid instruction }
  19. function cpuid_support : boolean;
  20. { returns true, if floating point is done by an emulator }
  21. function floating_point_emulation : boolean;
  22. { returns the contents of the cr0 register }
  23. function cr0 : longint;
  24. implementation
  25. function cpuid_support : boolean;assembler;
  26. {
  27. Check if the ID-flag can be changed, if changed then CpuID is supported.
  28. Tested under go32v1 and Linux on c6x86 with CpuID enabled and disabled (PFV)
  29. }
  30. asm
  31. pushf
  32. pushf
  33. pop eax
  34. mov ebx,eax
  35. xor eax,200000h
  36. push eax
  37. popf
  38. pushf
  39. pop eax
  40. popf
  41. and eax,200000h
  42. and ebx,200000h
  43. cmp eax,ebx
  44. setnz al
  45. end;
  46. function cr0 : longint;assembler;
  47. asm
  48. { mov eax,cr0 }
  49. end;
  50. function floating_point_emulation : boolean;
  51. begin
  52. {!!!! I don't know currently the position of the EM flag }
  53. floating_point_emulation:=(cr0 and $0)<>0;
  54. end;
  55. end.
  56. {
  57. $Log$
  58. Revision 1.2 1998-05-12 10:42:41 peter
  59. * moved getopts to inc/, all supported OS's need argc,argv exported
  60. + strpas, strlen are now exported in the systemunit
  61. * removed logs
  62. * removed $ifdef ver_above
  63. }