cpu.pp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998 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.5 1998-09-14 10:48:06 peter
  61. * FPC_ names
  62. * Heap manager is now system independent
  63. Revision 1.4 1998/08/11 00:04:46 peter
  64. * $ifdef ver0_99_5 updates
  65. Revision 1.3 1998/05/25 10:51:27 pierre
  66. * CR0 works now (written using DB to allow to use it we INTEL and ATT output)
  67. * floating_emulation bit set correctly
  68. Revision 1.2 1998/05/12 10:42:41 peter
  69. * moved getopts to inc/, all supported OS's need argc,argv exported
  70. + strpas, strlen are now exported in the systemunit
  71. * removed logs
  72. * removed $ifdef ver_above
  73. }