mmx.tex 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The MMX unit}
  22. This chapter describes the \file{MMX} unit. This unit allows you to use the
  23. \var{MMX} capabilities of the \fpc compiler. It was written by Florian
  24. Kl\"ampfl for the \var{I386} processor. It should work on all platforms that
  25. use the Intel processor.
  26. \section{Variables, Types and constants}
  27. The following types are defined in the \var{MMX} unit:
  28. \begin{verbatim}
  29. tmmxshortint = array[0..7] of shortint;
  30. tmmxbyte = array[0..7] of byte;
  31. tmmxword = array[0..3] of word;
  32. tmmxinteger = array[0..3] of integer;
  33. tmmxfixed = array[0..3] of fixed16;
  34. tmmxlongint = array[0..1] of longint;
  35. tmmxcardinal = array[0..1] of cardinal;
  36. { for the AMD 3D }
  37. tmmxsingle = array[0..1] of single;
  38. \end{verbatim}
  39. And the following pointers to the above types:
  40. \begin{verbatim}
  41. pmmxshortint = ^tmmxshortint;
  42. pmmxbyte = ^tmmxbyte;
  43. pmmxword = ^tmmxword;
  44. pmmxinteger = ^tmmxinteger;
  45. pmmxfixed = ^tmmxfixed;
  46. pmmxlongint = ^tmmxlongint;
  47. pmmxcardinal = ^tmmxcardinal;
  48. { for the AMD 3D }
  49. pmmxsingle = ^tmmxsingle;
  50. \end{verbatim}
  51. The following initialized constants allow you to determine if the computer
  52. has \var{MMX} extensions. They are set correctly in the unit's
  53. initialization code.
  54. \begin{verbatim}
  55. is_mmx_cpu : boolean = false;
  56. is_amd_3d_cpu : boolean = false;
  57. \end{verbatim}
  58. \section{Functions and Procedures}
  59. \begin{procedure}{Emms}
  60. \Declaration
  61. Procedure Emms ;
  62. \Description
  63. \var{Emms} sets all floating point registers to empty. This procedure must
  64. be called after you have used any \var{MMX} instructions, if you want to use
  65. floating point arithmetic. If you just want to move floating point data
  66. around, it isn't necessary to call this function, the compiler doesn't use
  67. the FPU registers when moving data. Only when doing calculations, you should
  68. use this function.
  69. \Errors
  70. None.
  71. \SeeAlso
  72. \progref
  73. \end{procedure}
  74. \begin{FPCList}
  75. \item[Example:]
  76. \begin{verbatim}
  77. Program MMXDemo;
  78. uses mmx;
  79. var
  80. d1 : double;
  81. a : array[0..10000] of double;
  82. i : longint;
  83. begin
  84. d1:=1.0;
  85. {$mmx+}
  86. { floating point data is used, but we do _no_ arithmetic }
  87. for i:=0 to 10000 do
  88. a[i]:=d2; { this is done with 64 bit moves }
  89. {$mmx-}
  90. emms; { clear fpu }
  91. { now we can do floating point arithmetic again }
  92. end.
  93. \end{verbatim}
  94. \end{FPCList}