cvs commit: de-docproj/books/developers-handbook/x86 chapter.sgml

From: Aron Schlesinger <as(at)doc.bsdgroup.de>
Date: Thu, 30 Aug 2007 18:35:51 GMT

as 2007-08-30 18:35:51 UTC

  FreeBSD ports repository

  Modified files:
    books/developers-handbook/x86 chapter.sgml
  Log:
  Kapitel 12.12 uebersetzt.
  
  Gesendet von: Fabian Borschel
  
  ToDo: die screen und programlisting -bloecke muessen gefixt werden.
  
  Revision Changes Path
  1.9 +1588 -1753 de-docproj/books/developers-handbook/x86/chapter.sgml
  
  Index: chapter.sgml
  ===================================================================
  RCS file: /home/cvs/de-docproj/books/developers-handbook/x86/chapter.sgml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -I$FreeBSDde.*$ -r1.8 -r1.9
  --- chapter.sgml 29 Aug 2007 19:37:48 -0000 1.8
  +++ chapter.sgml 30 Aug 2007 18:35:50 -0000 1.9
  @@ -3516,1462 +3516,1317 @@
   </sect1>
   
   <sect1 id="x86-fpu">
  -<title>Using the <acronym>FPU</acronym></title>
  -<para>
  -Strangely enough, most of assembly language literature does not
  -even mention the existence of the <acronym>FPU</acronym>,
  -or <emphasis>floating point unit</emphasis>, let alone discuss
  -programming it.
  -</para>
  -
  -<para>
  -Yet, never does assembly language shine more than when
  -we create highly optimized <acronym>FPU</acronym>
  -code by doing things that can be done <emphasis>only</emphasis> in assembly language.</para>
  -
  -<sect2 id="x86-fpu-organization"><title>Organization of the <acronym>FPU</acronym></title>
  -<para>
  -The <acronym>FPU</acronym> consists of 8 80&ndash;bit floating&ndash;point registers.
  -These are organized in a stack fashion&mdash;you can
  -<function>push</function> a value on <acronym>TOS</acronym>
  -(<emphasis>top of stack</emphasis>) and you can
  -<function>pop</function> it.
  -</para>
  -
  -<para>
  -That said, the assembly language op codes are not <function role="opcode">push</function>
  -and <function role="opcode">pop</function> because those are already taken.</para>
  -
  -<para>
  -You can <function>push</function> a value on <acronym>TOS</acronym>
  -by using <function role="opcode">fld</function>, <function role="opcode">fild</function>,
  -and <function role="opcode">fbld</function>. Several other op codes
  -let you <function>push</function> many common
  -<emphasis>constants</emphasis>&mdash;such as <emphasis>pi</emphasis>&mdash;on
  -the <acronym>TOS</acronym>.
  -</para>
  -
  -<para>
  -Similarly, you can <function>pop</function> a value by
  -using <function role="opcode">fst</function>, <function role="opcode">fstp</function>,
  -<function role="opcode">fist</function>, <function role="opcode">fistp</function>, and
  -<function role="opcode">fbstp</function>. Actually, only the op
  -codes that end with a <emphasis>p</emphasis> will
  -literally <function>pop</function> the value,
  -the rest will <function>store</function> it
  -somewhere else without removing it from
  -the <acronym>TOS</acronym>.
  -</para>
  -
  -<para>
  -We can transfer the data between the
  -<acronym>TOS</acronym> and the computer memory either as
  -a 32&ndash;bit, 64&ndash;bit, or 80&ndash;bit <emphasis>real</emphasis>,
  -a 16&ndash;bit, 32&ndash;bit, or 64&ndash;bit <emphasis>integer</emphasis>,
  -or an 80&ndash;bit <emphasis>packed decimal</emphasis>.
  -</para>
  -
  -<para>
  -The 80&ndash;bit <emphasis>packed decimal</emphasis> is
  -a special case of <emphasis>binary coded
  -decimal</emphasis> which is very convenient when
  -converting between the <acronym>ASCII</acronym>
  -representation of data and the internal
  -data of the <acronym>FPU</acronym>. It allows us to use
  -18 significant digits.
  -</para>
  -
  -<para>
  -No matter how we represent data in the memory,
  -the <acronym>FPU</acronym> always stores it in the 80&ndash;bit
  -<emphasis>real</emphasis> format in its registers.
  -</para>
  -
  -<para>
  -Its internal precision is at least 19 decimal
  -digits, so even if we choose to display results
  -as <acronym>ASCII</acronym> in the full
  -18&ndash;digit precision, we are still showing
  -correct results.
  -</para>
  -
  -<para>
  -We can perform mathematical operations on the
  -<acronym>TOS</acronym>: We can calculate its
  -<emphasis>sine</emphasis>, we can <emphasis>scale</emphasis> it
  -(i.e., we can multiply or divide it by a power
  -of 2), we can calculate its base&ndash;2
  -<emphasis>logarithm</emphasis>, and many other things.
  -</para>
  -
  -<para>
  -We can also <emphasis>multiply</emphasis> or
  -<emphasis>divide</emphasis> it by, <emphasis>add</emphasis>
  -it to, or <emphasis>subtract</emphasis> it from,
  -any of the <acronym>FPU</acronym> registers (including
  -itself).
  -</para>
  -
  -<para>
  -The official Intel op code for the
  -<acronym>TOS</acronym> is <varname role="register">st</varname>, and
  -for the <emphasis>registers</emphasis>
  -<varname role="register">st(0)</varname>&ndash;<varname role="register">st(7)</varname>.
  -<varname role="register">st</varname> and <varname role="register">st(0)</varname>, then,
  -refer to the same register.
  -</para>
  -
  -<para>
  -For whatever reasons, the original author of
  -<application>nasm</application> has decided to use
  -different op codes, namely
  -<varname role="register">st0</varname>&ndash;<varname role="register">st7</varname>.
  -In other words, there are no parentheses,
  -and the <acronym>TOS</acronym> is always
  -<varname role="register">st0</varname>, never just <function role="opcode">st</function>.
  -</para>
  -
  -<sect3 id="x86-fpu-packed-decimal">
  -<title>The Packed Decimal Format</title>
  -<para>
  -The <emphasis>packed decimal</emphasis> format
  -uses 10 bytes (80 bits) of
  -memory to represent 18 digits. The
  -number represented there is always an
  -<emphasis>integer</emphasis>.
  -</para>
  -
  -<tip>
  -<para>
  -You can use it to get decimal places
  -by multiplying the <acronym>TOS</acronym>
  -by a power of 10 first.
  -</para>
  -</tip>
  -
  -<para>
  -The highest bit of the highest byte
  -(byte 9) is the <emphasis>sign bit</emphasis>:
  -If it is set, the number is <emphasis>negative</emphasis>,
  -otherwise, it is <emphasis>positive</emphasis>.
  -The rest of the bits of this byte are unused/ignored.
  -</para>
  -
  -<para>
  -The remaining 9 bytes store the 18 digits
  -of the number: 2 digits per byte.</para>
  -
  -<para>
  -The <emphasis>more significant digit</emphasis> is
  -stored in the high <emphasis>nibble</emphasis>
  -(4 bits), the <emphasis>less significant
  -digit</emphasis> in the low <emphasis>nibble</emphasis>.
  -</para>
  -
  -<para>
  -That said, you might think that <constant>-1234567</constant>
  -would be stored in the memory like this (using
  -hexadecimal notation):
  -</para>
  -
  -<programlisting>
  -80 00 00 00 00 00 01 23 45 67
  -</programlisting>
  -<para>
  -Alas it is not! As with everything else of Intel make,
  -even the <emphasis>packed decimal</emphasis> is
  -<emphasis>little&ndash;endian</emphasis>.</para>
  -
  -<para>
  -That means our <constant>-1234567</constant>
  -is stored like this:
  -</para>
  -
  -<programlisting>
  -67 45 23 01 00 00 00 00 00 80
  -</programlisting>
  -<para>
  -Remember that, or you will be pulling your hair out
  -in desperation!
  -</para>
  -
  -<note>
  -<para>
  -The book to read&mdash;if you can find it&mdash;is Richard Startz'
  -<ulink url="http://www.int80h.org/cgi-bin/isbn?isbn=013246604X">8087/80287/80387
  -for the IBM PC &amp; Compatibles</ulink>.
  -Though it does seem to take the fact about the
  -little&ndash;endian storage of the <emphasis>packed
  -decimal</emphasis> for granted. I kid you not about the
  -desperation of trying to figure out what was wrong

----------------------------------------------
Diff block truncated. (Max lines = 200)
----------------------------------------------

To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-cvs-doc" in the body of the message
Received on Thu 30 Aug 2007 - 20:37:15 CEST

search this site