cpu.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. DB 0Fh,20h,0C0h
  49. { mov eax,cr0
  50. special registers are not allowed in the assembler
  51. parsers }
  52. end;
  53. function floating_point_emulation : boolean;
  54. begin
  55. {!!!! I don't know currently the position of the EM flag }
  56. { $4 after Ralf Brown's list }
  57. floating_point_emulation:=(cr0 and $4)<>0;
  58. end;
  59. end.
  60. {
  61. $Log$
  62. Revision 1.3 1998-05-25 10:51:27 pierre
  63. * CR0 works now (written using DB to allow to use it we INTEL and ATT output)
  64. * floating_emulation bit set correctly
  65. Revision 1.2 1998/05/12 10:42:41 peter
  66. * moved getopts to inc/, all supported OS's need argc,argv exported
  67. + strpas, strlen are now exported in the systemunit
  68. * removed logs
  69. * removed $ifdef ver_above
  70. }