cpu.pp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. This unit contains some routines to get informations about the
  6. processor
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit cpu;
  14. interface
  15. { returns true, if the processor supports the cpuid instruction }
  16. function cpuid_support : boolean;
  17. { returns true, if floating point is done by an emulator }
  18. function floating_point_emulation : boolean;
  19. { returns the contents of the cr0 register }
  20. function cr0 : longint;
  21. implementation
  22. {$ASMMODE INTEL}
  23. function cpuid_support : boolean;assembler;
  24. {
  25. Check if the ID-flag can be changed, if changed then CpuID is supported.
  26. Tested under go32v1 and Linux on c6x86 with CpuID enabled and disabled (PFV)
  27. }
  28. asm
  29. pushf
  30. pushf
  31. pop eax
  32. mov ebx,eax
  33. xor eax,200000h
  34. push eax
  35. popf
  36. pushf
  37. pop eax
  38. popf
  39. and eax,200000h
  40. and ebx,200000h
  41. cmp eax,ebx
  42. setnz al
  43. end;
  44. function cr0 : longint;assembler;
  45. asm
  46. DB 0Fh,20h,0C0h
  47. { mov eax,cr0
  48. special registers are not allowed in the assembler
  49. parsers }
  50. end;
  51. function floating_point_emulation : boolean;
  52. begin
  53. {!!!! I don't know currently the position of the EM flag }
  54. { $4 after Ralf Brown's list }
  55. floating_point_emulation:=(cr0 and $4)<>0;
  56. end;
  57. end.
  58. {
  59. $Log$
  60. Revision 1.7 2000-02-09 16:59:29 peter
  61. * truncated log
  62. Revision 1.6 2000/01/07 16:41:32 daniel
  63. * copyright 2000
  64. }