Remove colour attributes from body and strip most of the font tags out

This commit is contained in:
James Gregory 2013-12-30 13:57:02 +11:00
commit c1f88ddb41
362 changed files with 1632 additions and 1706 deletions

View file

@ -24,7 +24,7 @@
<!--CHAPTER=09//-->
<!--PAGES=167-172//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//--></HEAD><BODY LINK=#0000FF ALINK=#000099 VLINK=#0000FF BGCOLOR=#FFFFFF>
<!--UNASSIGNED2//--></HEAD><body>
<CENTER>
<TABLE BORDER>
@ -36,9 +36,8 @@
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 9<BR>Hints My Readers Gave Me
</FONT></H2>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Optimization Odds and Ends from the Field</FONT></H3>
<H2><A NAME="Heading1"></A>Chapter 9<BR>Hints My Readers Gave Me</H2>
<H3><A NAME="Heading2"></A>Optimization Odds and Ends from the Field</H3>
<P>Back in high school, I took a pre-calculus class from Mr. Bourgeis, whose most notable characteristics were incessant pacing and truly enormous feet. My friend Barry, who sat in the back row, right behind me, claimed that it was because of his large feet that Mr. Bourgeis was so restless. Those feet were <I>so</I> heavy, Barry hypothesized, that if Mr. Bourgeis remained in any one place for too long, the floor would give way under the strain, plunging the unfortunate teacher deep into the mantle of the Earth and possibly all the way through to China. Many amusing cartoons were drawn to this effect.</P>
<P>Unfortunately, Barry was too busy drawing cartoons, or, alternatively, sleeping, to actually learn any math. In the long run, that didn&rsquo;t turn out to be a handicap for Barry, who went on to become vice-president of sales for a ham-packing company, where presumably he was rarely called upon to derive the quadratic equation. Barry&rsquo;s lack of scholarship caused some problems back then, though. On one memorable occasion, Barry was half-asleep, with his eyes open but unfocused and his chin balanced on his hand in the classic &ldquo;if I fall asleep my head will fall off my hand and I&rsquo;ll wake up&rdquo; posture, when Mr. Bourgeis popped a killer problem:</P>
<P>&ldquo;Barry, solve this for X, please.&rdquo; On the blackboard lay the equation:</P>
@ -58,7 +57,7 @@ X - 1 = 0
<P>&ldquo;Well, I could hear the answer all the way up here. Surely you could hear it just one row away?&rdquo;</P>
<P>The class went wild. They might as well have sent us home early for all we accomplished the rest of the day.</P>
<P>I like to think I know more about performance programming than Barry knew about math. Nonetheless, I always welcome good ideas and comments, and many readers have sent me a slew of those over the years. So in this chapter, I think I&rsquo;ll return the favor by devoting a chapter to reader feedback.</P>
<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">Another Look at LEA</FONT></H4>
<H4 ALIGN="LEFT"><A NAME="Heading3"></A>Another Look at LEA</H4>
<P>Several people have pointed out that while <B>LEA</B> is great for performing certain additions (see Chapter 6), it isn&rsquo;t a perfect replacement for <B>ADD</B>. What&rsquo;s the difference? <B>LEA</B>, an addressing instruction by trade, doesn&rsquo;t affect the flags, while the arithmetic <B>ADD</B> instruction most certainly does. This is no problem when performing additions that involve only quantities that fit in one machine word (32 bits in 386 protected mode, 16 bits otherwise), but it renders <B>LEA</B> useless for multiword operations, which use the Carry flag to tie together partial results. For example, these instructions</P>
<!-- CODE SNIP //-->
<PRE>
@ -92,7 +91,7 @@ ADDLOOP:
<P>(Yes, I could use <B>LODSD</B> instead of <B>MOV/LEA</B>; I&rsquo;m just illustrating a point here. Besides, <B>LODS</B> is only 1 cycle faster than <B>MOV/LEA</B> on the 386, and is actually more than twice as slow on the 486.) If we used <B>ADD</B> rather than <B>LEA</B> to advance the pointers, the carry from one <B>ADC</B> to the next would have to be preserved with either <B>PUSHF/POPF</B> or <B>LAHF/SAHF</B>. (Alternatively, we could use multiple <B>INC</B>s, since <B>INC</B> doesn&rsquo;t affect the Carry flag.)</P>
<P>In short, <B>LEA</B> is indeed different from <B>ADD</B>. Sometimes it&rsquo;s better. Sometimes not; that&rsquo;s the nature of the various instruction substitutions and optimizations that will occur to you over time. There&rsquo;s no such thing as &ldquo;best&rdquo; instructions on the x86; it all depends on what you&rsquo;re trying to do.</P>
<P>But there sure are a lot of interesting options, aren&rsquo;t there?</P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">The Kennedy Portfolio</FONT></H4>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A>The Kennedy Portfolio</H4>
<P>Reader John Kennedy regularly passes along intriguing assembly programming tricks, many of which I&rsquo;ve never seen mentioned anywhere else. John likes to optimize for size, whereas I lean more toward speed, but many of his optimizations are good for both purposes. Here are a few of my favorites:
</P>
<P>John&rsquo;s code for setting AX to its absolute value is:</P>
@ -149,7 +148,7 @@ CopyDone:
<hr width="90%" size="1" noshade>
<div align="center">
<font face="Verdana,sans-serif" size="1">Graphics Programming Black Book &copy; 2001 Michael Abrash</font>
Graphics Programming Black Book &copy; 2001 Michael Abrash
</div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->