cpu.pp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 (Syn)
  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.1 1998-03-25 11:18:42 root
  59. Initial revision
  60. Revision 1.6 1998/03/03 23:20:14 florian
  61. * mov eax,cr0 isn't yet recognized by the asm parser, removed
  62. Revision 1.5 1998/03/03 22:47:00 florian
  63. * small problems fixed
  64. Revision 1.4 1998/02/04 23:00:58 florian
  65. - mmx stuff moved to mmx unit
  66. Revision 1.3 1998/01/26 11:59:17 michael
  67. + Added log at the end
  68. Working file: rtl/i386/cpu.pp
  69. description:
  70. ----------------------------
  71. revision 1.2
  72. date: 1997/12/01 12:34:37; author: michael; state: Exp; lines: +12 -6
  73. + added copyright reference in header.
  74. ----------------------------
  75. revision 1.1
  76. date: 1997/11/27 22:49:04; author: florian; state: Exp;
  77. - CPU.PP added
  78. - some bugs in DOS fixed (especially for go32v1)
  79. - the win32 system unit is now compilable
  80. =============================================================================
  81. History:
  82. 6th november 1997:
  83. + inital version (FK)
  84. 27th november 1997:
  85. + cpuid_support, thanks to synopsis (FK)
  86. }