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. {$ifdef VER0_99_5}
  23. {$I386_INTEL}
  24. {$endif}
  25. {$ASMMODE INTEL}
  26. function cpuid_support : boolean;assembler;
  27. {
  28. Check if the ID-flag can be changed, if changed then CpuID is supported.
  29. Tested under go32v1 and Linux on c6x86 with CpuID enabled and disabled (PFV)
  30. }
  31. asm
  32. pushf
  33. pushf
  34. pop eax
  35. mov ebx,eax
  36. xor eax,200000h
  37. push eax
  38. popf
  39. pushf
  40. pop eax
  41. popf
  42. and eax,200000h
  43. and ebx,200000h
  44. cmp eax,ebx
  45. setnz al
  46. end;
  47. function cr0 : longint;assembler;
  48. asm
  49. DB 0Fh,20h,0C0h
  50. { mov eax,cr0
  51. special registers are not allowed in the assembler
  52. parsers }
  53. end;
  54. function floating_point_emulation : boolean;
  55. begin
  56. {!!!! I don't know currently the position of the EM flag }
  57. { $4 after Ralf Brown's list }
  58. floating_point_emulation:=(cr0 and $4)<>0;
  59. end;
  60. end.
  61. {
  62. $Log$
  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. }