Strip comments and inline ids onto h*

This commit is contained in:
James Gregory 2013-12-30 15:11:04 +11:00
commit 0f5f617adb
362 changed files with 2519 additions and 6694 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: The Best Optimizer Is between Your Ears</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: The Best Optimizer Is between Your Ears</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="01" /> <meta name="chapter" content="01" />
<meta name="pages" content="010-013" /> <meta name="pages" content="010-013" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -165,7 +158,7 @@
</tr> </tr>
</table> </table>
<p><b>LISTING 1.2 L1-2.C</b></p><!-- CODE //--> <p><b>LISTING 1.2 L1-2.C</b></p>
<pre> <pre>
/* /*
* Program to calculate the 16-bit checksum of the stream of bytes * Program to calculate the 16-bit checksum of the stream of bytes
@ -199,9 +192,9 @@ main(int argc, char *argv[]) {
printf(&ldquo;The checksum is: %u\n&rdquo;, Checksum); printf(&ldquo;The checksum is: %u\n&rdquo;, Checksum);
exit(0); exit(0);
} }
</pre><!-- END CODE //--> </pre>
<p><b>LISTING 1.3 L1-3.ASM</b></p><!-- CODE //--> <p><b>LISTING 1.3 L1-3.ASM</b></p>
<pre> <pre>
; Assembler subroutine to perform a 16-bit checksum on the file ; Assembler subroutine to perform a 16-bit checksum on the file
; opened on the passed-in handle. Stores the result in the ; opened on the passed-in handle. Stores the result in the
@ -267,13 +260,13 @@ Done:
ret ret
_ChecksumFileendp _ChecksumFileendp
end end
</pre><!-- END CODE //--> </pre>
<p>The lesson is clear: Optimization makes code faster, but without proper design, optimization just creates fast slow code.</p> <p>The lesson is clear: Optimization makes code faster, but without proper design, optimization just creates fast slow code.</p>
<p>Well, then, how are we going to improve our design? Before we can do that, we have to understand what&rsquo;s wrong with the current design.</p> <p>Well, then, how are we going to improve our design? Before we can do that, we have to understand what&rsquo;s wrong with the current design.</p>
<h4 align="left"><a id="Heading9"></a>Know the Territory</h4> <h4 align="left" id="Heading9">Know the Territory</h4>
<p>Just why is Listing 1.1 so slow? In a word: overhead. The C library implements the <b>read()</b> function by calling DOS to read the desired number of bytes. (I figured this out by watching the code execute with a debugger, but you can buy library source code from both Microsoft and Borland.) That means that Listing 1.1 (and Listing 1.3 as well) executes one DOS function per byte processed&mdash;and DOS functions, especially this one, come with a lot of overhead.</p> <p>Just why is Listing 1.1 so slow? In a word: overhead. The C library implements the <b>read()</b> function by calling DOS to read the desired number of bytes. (I figured this out by watching the code execute with a debugger, but you can buy library source code from both Microsoft and Borland.) That means that Listing 1.1 (and Listing 1.3 as well) executes one DOS function per byte processed&mdash;and DOS functions, especially this one, come with a lot of overhead.</p>
@ -302,10 +295,6 @@ _ChecksumFileendp
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Assume Nothing</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Assume Nothing</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="03" /> <meta name="chapter" content="03" />
<meta name="pages" content="035-042" /> <meta name="pages" content="035-042" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 3.1 PZTIMER.ASM</b></p><!-- CODE //--> <p><b>LISTING 3.1 PZTIMER.ASM</b></p>
<pre> <pre>
; The precision Zen timer (PZTIMER.ASM) ; The precision Zen timer (PZTIMER.ASM)
; ;
@ -478,7 +471,7 @@ ZTimerReport endp
Code ends Code ends
end end
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -497,10 +490,6 @@ Code ends
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="05" /> <meta name="chapter" content="05" />
<meta name="pages" content="118-121" /> <meta name="pages" content="118-121" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 5.1 SEARCH.C</b></p><!-- CODE //--> <p><b>LISTING 5.1 SEARCH.C</b></p>
<pre> <pre>
/* Program to search the file specified by the first command-line /* Program to search the file specified by the first command-line
* argument for the string specified by the second command-line * argument for the string specified by the second command-line
@ -204,7 +197,7 @@ main(int argc, char *argv[]) {
exit(Found); /* Return the found/not found status as the exit(Found); /* Return the found/not found status as the
DOS errorlevel */ DOS errorlevel */
} }
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -223,10 +216,6 @@ main(int argc, char *argv[]) {
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="05" /> <meta name="chapter" content="05" />
<meta name="pages" content="121-122" /> <meta name="pages" content="121-122" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<h3><a id="Heading8"></a>Interpreting Where the Cycles Go</h3> <h3 id="Heading8">Interpreting Where the Cycles Go</h3>
<p>To boost the overall performance of Listing 5.1, I would normally convert <b>SearchForString()</b> to assembly language at this point. However, I&rsquo;m not going to do that, and the reason is as important a lesson as any discussion of optimized assembly code is likely to be. Take a moment to examine some interesting performance aspects of the C implementation, and all should become much clearer.</p> <p>To boost the overall performance of Listing 5.1, I would normally convert <b>SearchForString()</b> to assembly language at this point. However, I&rsquo;m not going to do that, and the reason is as important a lesson as any discussion of optimized assembly code is likely to be. Take a moment to examine some interesting performance aspects of the C implementation, and all should become much clearer.</p>
@ -53,7 +46,7 @@
<p>Not likely.</p> <p>Not likely.</p>
<h4 align="left"><a id="Heading9"></a>Knowing When Assembly Is Pointless</h4> <h4 align="left" id="Heading9">Knowing When Assembly Is Pointless</h4>
<p>So that&rsquo;s why we&rsquo;re not going to go to assembly language in this example&mdash;which is not to say it would never be worth converting the search engine in Listing 5.1 to assembly.</p> <p>So that&rsquo;s why we&rsquo;re not going to go to assembly language in this example&mdash;which is not to say it would never be worth converting the search engine in Listing 5.1 to assembly.</p>
@ -78,10 +71,6 @@
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Crossing the Border</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="05" /> <meta name="chapter" content="05" />
<meta name="pages" content="122-123" /> <meta name="pages" content="122-123" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -53,7 +46,7 @@
<p>Restartable blocks do minimize the overhead of DOS file-access calls in Listing 5.1; it&rsquo;s just that there&rsquo;s no way to reduce that overhead to the point where it becomes worth attempting to further improve the performance of our relatively efficient search engine. Although the search engine is by no means fully optimized, it&rsquo;s nonetheless as fast as there&rsquo;s any reason for it to be, given the balance of performance among the components of this program.</p> <p>Restartable blocks do minimize the overhead of DOS file-access calls in Listing 5.1; it&rsquo;s just that there&rsquo;s no way to reduce that overhead to the point where it becomes worth attempting to further improve the performance of our relatively efficient search engine. Although the search engine is by no means fully optimized, it&rsquo;s nonetheless as fast as there&rsquo;s any reason for it to be, given the balance of performance among the components of this program.</p>
<h3><a id="Heading10"></a>Always Look Where Execution Is Going</h3> <h3 id="Heading10">Always Look Where Execution Is Going</h3>
<p>I&rsquo;ve explained two important lessons: Know when it&rsquo;s worth optimizing further, and use restartable blocks to process large data sets as a series of blocks, with each block handled at high speed. The first lesson is less obvious than it seems.</p> <p>I&rsquo;ve explained two important lessons: Know when it&rsquo;s worth optimizing further, and use restartable blocks to process large data sets as a series of blocks, with each block handled at high speed. The first lesson is less obvious than it seems.</p>
@ -90,10 +83,6 @@
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Speeding Up C with Assembly Language</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Speeding Up C with Assembly Language</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="08" /> <meta name="chapter" content="08" />
<meta name="pages" content="163-166" /> <meta name="pages" content="163-166" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -39,7 +32,7 @@
<p>Listings 8.5 and 8.6 together go the final step and change the rules in favor of assembly language. Listing 8.5 creates the same list of linked blocks as Listing 8.1. However, instead of storing an array of structures within each block, it stores <i>two</i> arrays in each block, one consisting of ID numbers and the other consisting of the corresponding values, as shown in Figure 8.3. No information is lost; the data is merely rearranged.</p> <p>Listings 8.5 and 8.6 together go the final step and change the rules in favor of assembly language. Listing 8.5 creates the same list of linked blocks as Listing 8.1. However, instead of storing an array of structures within each block, it stores <i>two</i> arrays in each block, one consisting of ID numbers and the other consisting of the corresponding values, as shown in Figure 8.3. No information is lost; the data is merely rearranged.</p>
<p><b>LISTING 8.5 L8-5.C</b></p><!-- CODE //--> <p><b>LISTING 8.5 L8-5.C</b></p>
<pre> <pre>
/* Program to search an array spanning a linked list of variable- /* Program to search an array spanning a linked list of variable-
sized blocks, for all entries with a specified ID number, sized blocks, for all entries with a specified ID number,
@ -59,11 +52,10 @@ void main(void);
void exit(int); void exit(int);
extern unsigned int FindIDAverage2(unsigned int, extern unsigned int FindIDAverage2(unsigned int,
struct BlockHeader *); struct BlockHeader *);
</pre><!-- END CODE //--> </pre>
<p><a id="Fig3"><!-- </A><A HREF="javascript:displayWindow('images/08-03.jpg',413,261 )"> --><img src="images/08-03.jpg" /><br /> <p><a id="Fig3"><img src="images/08-03.jpg" /><br />
<!-- </A> <b>Figure 8.3</b></a>&nbsp;&nbsp;<i>Linked array storage format (version 2).</i></p>
<BR><A HREF="javascript:displayWindow('images/08-03.jpg',413,261)"> --><b>Figure 8.3</b></a>&nbsp;&nbsp;<i>Linked array storage format (version 2).</i></p><!-- CODE //-->
<pre> <pre>
/* Structure that starts each variable-sized block */ /* Structure that starts each variable-sized block */
struct BlockHeader { struct BlockHeader {
@ -117,9 +109,9 @@ void main(void) {
IDToFind, FindIDAverage2(IDToFind, BaseArrayBlockPointer)); IDToFind, FindIDAverage2(IDToFind, BaseArrayBlockPointer));
exit(0); exit(0);
} }
</pre><!-- END CODE //--> </pre>
<p><b>LISTING 8.6 L8-6.ASM</b></p><!-- CODE //--> <p><b>LISTING 8.6 L8-6.ASM</b></p>
<pre> <pre>
; Alternative optimized assembly language version of FindIDAverage ; Alternative optimized assembly language version of FindIDAverage
; requires data organized as two arrays within each block rather ; requires data organized as two arrays within each block rather
@ -188,7 +180,7 @@ Done: pop si ;Restore C register variables
ret ret
_FindIDAverage2 ENDP _FindIDAverage2 ENDP
end end
</pre><!-- END CODE //--> </pre>
<p>The whole point of this rearrangement is to allow us to use <b>REP SCASW</b> to search through each block, and that&rsquo;s exactly what <b>FindIDAverage2</b> in Listing 8.6 does. The result: Listing 8.6 calculates the average about <i>three times</i> as fast as the original C implementation and more than twice as fast as Listing 8.4, heavily optimized as the latter code is.</p> <p>The whole point of this rearrangement is to allow us to use <b>REP SCASW</b> to search through each block, and that&rsquo;s exactly what <b>FindIDAverage2</b> in Listing 8.6 does. The result: Listing 8.6 calculates the average about <i>three times</i> as fast as the original C implementation and more than twice as fast as Listing 8.4, heavily optimized as the latter code is.</p>
@ -211,10 +203,6 @@ _FindIDAverage2 ENDP
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Hints My Readers Gave Me</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Hints My Readers Gave Me</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="09" /> <meta name="chapter" content="09" />
<meta name="pages" content="175-178" /> <meta name="pages" content="175-178" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -49,11 +42,10 @@
</tr> </tr>
</table> </table>
<p><a id="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/09-02.jpg',409,306 )"> --><img src="images/09-02.jpg" /><br /> <p><a id="Fig2"><img src="images/09-02.jpg" /><br />
<!-- </A> <b>Figure 9.2</b></a>&nbsp;&nbsp;<i>Faster searching method for locating a text string.</i></p>
<BR><A HREF="javascript:displayWindow('images/09-02.jpg',409,306)"> --><b>Figure 9.2</b></a>&nbsp;&nbsp;<i>Faster searching method for locating a text string.</i></p>
<p><b>LISTING 9.1 L9-1.ASM</b></p><!-- CODE //--> <p><b>LISTING 9.1 L9-1.ASM</b></p>
<pre> <pre>
; Searches a text buffer for a text string. Uses REPNZ SCASB to sca"n ; Searches a text buffer for a text string. Uses REPNZ SCASB to sca"n
; the buffer for locations that match the first character of the ; the buffer for locations that match the first character of the
@ -146,7 +138,7 @@ FindStringDone:
ret ret
_FindStringendp _FindStringendp
end end
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -165,10 +157,6 @@ _FindStringendp
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Hints My Readers Gave Me</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Hints My Readers Gave Me</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="09" /> <meta name="chapter" content="09" />
<meta name="pages" content="178-180" /> <meta name="pages" content="178-180" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 9.2 L9-2.ASM</b></p><!-- CODE //--> <p><b>LISTING 9.2 L9-2.ASM</b></p>
<pre> <pre>
; Searches a text buffer for a text string. Uses REPNZ SCASB to scan ; Searches a text buffer for a text string. Uses REPNZ SCASB to scan
; the buffer for locations that match a specified character of the ; the buffer for locations that match a specified character of the
@ -135,9 +128,9 @@ FindStringDone:
ret ret
_FindStringendp _FindStringendp
end end
</pre><!-- END CODE //--> </pre>
<p><b>LISTING 9.3 L9-3.C</b></p><!-- CODE //--> <p><b>LISTING 9.3 L9-3.C</b></p>
<pre> <pre>
/* Program to exercise buffer-search routines in Listings 9.1 &amp; 9.2 */ /* Program to exercise buffer-search routines in Listings 9.1 &amp; 9.2 */
#include &lt;stdio.h&gt; #include &lt;stdio.h&gt;
@ -171,7 +164,7 @@ void main() {
strncpy(TempBuffer, MatchPtr, DISPLAY_LENGTH)); strncpy(TempBuffer, MatchPtr, DISPLAY_LENGTH));
} }
} }
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -190,10 +183,6 @@ void main() {
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Patient Coding, Faster Code</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Patient Coding, Faster Code</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="10" /> <meta name="chapter" content="10" />
<meta name="pages" content="193-196" /> <meta name="pages" content="193-196" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -43,9 +36,8 @@
<p>Listing 10.1 is an implementation of the brute-force approach to GCD calculation. Table 10.1 shows how long it takes this approach to find the GCD for several integer pairs. As expected, performance is extremely poor when iS is large.</p> <p>Listing 10.1 is an implementation of the brute-force approach to GCD calculation. Table 10.1 shows how long it takes this approach to find the GCD for several integer pairs. As expected, performance is extremely poor when iS is large.</p>
<p><a id="Fig1"><!-- </A><A HREF="javascript:displayWindow('images/10-01.jpg',411,233 )"> --><img src="images/10-01.jpg" /><br /> <p><a id="Fig1"><img src="images/10-01.jpg" /><br />
<!-- </A> <b>Figure 10.1</b></a>&nbsp;&nbsp;<i>Using a brute-force algorithm to find a GCD.</i></p>
<BR><A HREF="javascript:displayWindow('images/10-01.jpg',411,233)"> --><b>Figure 10.1</b></a>&nbsp;&nbsp;<i>Using a brute-force algorithm to find a GCD.</i></p>
<table width="100%"> <table width="100%">
<tr> <tr>
@ -222,7 +214,7 @@
</tr> </tr>
</table> </table>
<p><b>LISTING 10.1 L10-1.C</b></p><!-- CODE //--> <p><b>LISTING 10.1 L10-1.C</b></p>
<pre> <pre>
/* Finds and returns the greatest common divisor of two positive /* Finds and returns the greatest common divisor of two positive
integers. Works by trying every integral divisor between the integers. Works by trying every integral divisor between the
@ -246,13 +238,13 @@ unsigned int gcd(unsigned int int1, unsigned int int2) {
; ;
return(trial_divisor); return(trial_divisor);
} }
</pre><!-- END CODE //--> </pre>
<h4 align="left"><a id="Heading5"></a>Wasted Breakthroughs</h4> <h4 align="left" id="Heading5">Wasted Breakthroughs</h4>
<p>Sedgewick&rsquo;s first solution to the GCD problem was pretty much the one I came up with. He then pointed out that the GCD of iL and iS is the same as the GCD of iL-iS and iS. This was obvious (once Sedgewick pointed it out); by the very nature of division, any number that divides iL evenly nL times and iS evenly nS times must divide iL-iS evenly nL-nS times. Given that insight, I immediately designed a new, faster approach, shown in Listing 10.2.</p> <p>Sedgewick&rsquo;s first solution to the GCD problem was pretty much the one I came up with. He then pointed out that the GCD of iL and iS is the same as the GCD of iL-iS and iS. This was obvious (once Sedgewick pointed it out); by the very nature of division, any number that divides iL evenly nL times and iS evenly nS times must divide iL-iS evenly nL-nS times. Given that insight, I immediately designed a new, faster approach, shown in Listing 10.2.</p>
<p><b>LISTING 10.2 L10-2.C</b></p><!-- CODE //--> <p><b>LISTING 10.2 L10-2.C</b></p>
<pre> <pre>
/* Finds and returns the greatest common divisor of two positive /* Finds and returns the greatest common divisor of two positive
integers. Works by subtracting the smaller integer from the integers. Works by subtracting the smaller integer from the
@ -283,7 +275,7 @@ unsigned int gcd(unsigned int int1, unsigned int int2) {
/* Now recursively call this function to continue the process */ /* Now recursively call this function to continue the process */
return(gcd(int1, int2)); return(gcd(int1, int2));
} }
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -302,10 +294,6 @@ unsigned int gcd(unsigned int int1, unsigned int int2) {
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Patient Coding, Faster Code</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Patient Coding, Faster Code</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="10" /> <meta name="chapter" content="10" />
<meta name="pages" content="200-203" /> <meta name="pages" content="200-203" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 10.5 L10-5.ASM</b></p><!-- CODE //--> <p><b>LISTING 10.5 L10-5.ASM</b></p>
<pre> <pre>
; Finds and returns the greatest common divisor of two integers. ; Finds and returns the greatest common divisor of two integers.
; Uses Euclid&rsquo;s algorithm: divides the larger integer by the ; Uses Euclid&rsquo;s algorithm: divides the larger integer by the
@ -126,7 +119,7 @@ Done:
ret ret
_gcd endp _gcd endp
end end
</pre><!-- END CODE //--> </pre>
<p>Assembly language optimization is pattern matching on a local scale. Frankly, it&rsquo;s also the sort of boring, brute-force work that people are lousy at; compilers could out-optimize you at this level with one pass tied behind their back <i>if</i> they knew as much about the code you&rsquo;re writing as you do, which they don&rsquo;t.</p> <p>Assembly language optimization is pattern matching on a local scale. Frankly, it&rsquo;s also the sort of boring, brute-force work that people are lousy at; compilers could out-optimize you at this level with one pass tied behind their back <i>if</i> they knew as much about the code you&rsquo;re writing as you do, which they don&rsquo;t.</p>
@ -163,10 +156,6 @@ _gcd endp
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Boyer-Moore String Searching</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Boyer-Moore String Searching</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="14" /> <meta name="chapter" content="14" />
<meta name="pages" content="267-268" /> <meta name="pages" content="267-268" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -221,10 +214,6 @@
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Boyer-Moore String Searching</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Boyer-Moore String Searching</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="14" /> <meta name="chapter" content="14" />
<meta name="pages" content="271-274" /> <meta name="pages" content="271-274" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 14.3 L14-3.ASM</b></p><!-- CODE //--> <p><b>LISTING 14.3 L14-3.ASM</b></p>
<pre> <pre>
; Searches a buffer for a specified pattern. In case of a mismatch, ; Searches a buffer for a specified pattern. In case of a mismatch,
; uses the value of the mismatched byte to skip across as many ; uses the value of the mismatched byte to skip across as many
@ -199,7 +192,7 @@ Done:
ret ret
_FindString endp _FindString endp
end end
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -218,10 +211,6 @@ _FindString endp
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Linked Lists and Unintended Challenges</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: Linked Lists and Unintended Challenges</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="15" /> <meta name="chapter" content="15" />
<meta name="pages" content="290-293" /> <meta name="pages" content="290-293" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 15.7 L15-7.ASM</b></p><!-- CODE //--> <p><b>LISTING 15.7 L15-7.ASM</b></p>
<pre> <pre>
; C near-callable assembly function for inserting a new node in a ; C near-callable assembly function for inserting a new node in a
; linked list sorted by ascending order of the Value field. The list ; linked list sorted by ascending order of the Value field. The list
@ -98,9 +91,9 @@ SearchLoop:
ret ret
_InsertNodeSorted endp _InsertNodeSorted endp
end end
</pre><!-- END CODE //--> </pre>
<p><b>LISTING 15.8 L15-8.C</b></p><!-- CODE //--> <p><b>LISTING 15.8 L15-8.C</b></p>
<pre> <pre>
/* Sample linked list program. Tested with Borland C++. */ /* Sample linked list program. Tested with Borland C++. */
#include &lt;stdlib.h&gt; #include &lt;stdlib.h&gt;
@ -183,9 +176,9 @@ void main()
} }
} }
} }
</pre><!-- END CODE //--> </pre>
<h3><a id="Heading6"></a>Hi/Lo in 24 Bytes</h3> <h3 id="Heading6">Hi/Lo in 24 Bytes</h3>
<p>In one of my <i>PC TECHNIQUES</i> &ldquo;Pushing the Envelope&rdquo; columns, I passed along one of David Stafford&rsquo;s fiendish programming puzzles: Write a C-callable function to find the greatest or smallest unsigned <b>int</b>. Not a big deal&mdash;except that David had <i>already</i> done it in 24 bytes, so the challenge was to do it in 24 bytes or less.</p> <p>In one of my <i>PC TECHNIQUES</i> &ldquo;Pushing the Envelope&rdquo; columns, I passed along one of David Stafford&rsquo;s fiendish programming puzzles: Write a C-callable function to find the greatest or smallest unsigned <b>int</b>. Not a big deal&mdash;except that David had <i>already</i> done it in 24 bytes, so the challenge was to do it in 24 bytes or less.</p>
@ -195,7 +188,7 @@ void main()
<p>Yes, a 24-byte hi/lo function is possible, anatomically improbable as it might seem. Which I guess goes to show that when one of David&rsquo;s puzzles seems less than impossible, odds are you&rsquo;re missing something. Listing 15.9 is David&rsquo;s 24-byte solution, from which a lot may be learned if one reads closely enough.</p> <p>Yes, a 24-byte hi/lo function is possible, anatomically improbable as it might seem. Which I guess goes to show that when one of David&rsquo;s puzzles seems less than impossible, odds are you&rsquo;re missing something. Listing 15.9 is David&rsquo;s 24-byte solution, from which a lot may be learned if one reads closely enough.</p>
<p><b>LISTING 15.9 L15-9.ASM</b></p><!-- CODE //--> <p><b>LISTING 15.9 L15-9.ASM</b></p>
<pre> <pre>
; Find the greatest or smallest unsigned int. ; Find the greatest or smallest unsigned int.
; C callable (small model); 24 bytes. ; C callable (small model); 24 bytes.
@ -224,7 +217,7 @@ around: ja save
jnz top jnz top
ret ret
</pre><!-- END CODE //--> </pre>
<p>Before I end this chapter, let me say that I get a lot of feedback from my readers, and it&rsquo;s much appreciated. Keep those cards, letters, and email messages coming. And if any of you know Jeannie Schweigert, have her drop me a line and let me know how she&rsquo;s doing these days....</p> <p>Before I end this chapter, let me say that I get a lot of feedback from my readers, and it&rsquo;s much appreciated. Keep those cards, letters, and email messages coming. And if any of you know Jeannie Schweigert, have her drop me a line and let me know how she&rsquo;s doing these days....</p>
@ -245,10 +238,6 @@ around: ja save
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: There Ain't No Such Thing as the Fastest Code</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: There Ain't No Such Thing as the Fastest Code</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="16" /> <meta name="chapter" content="16" />
<meta name="pages" content="308-311" /> <meta name="pages" content="308-311" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -165,7 +158,7 @@
</tr> </tr>
</table> </table>
<p><b>LISTING 16.5 QSCAN3.ASM</b></p><!-- CODE //--> <p><b>LISTING 16.5 QSCAN3.ASM</b></p>
<pre> <pre>
; QSCAN3.ASM ; QSCAN3.ASM
; David Stafford ; David Stafford
@ -345,7 +338,7 @@ jumping.
.fardata WordTable .fardata WordTable
include qscan3.inc ;built by MAKETAB include qscan3.inc ;built by MAKETAB
end end
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -364,10 +357,6 @@ jumping.
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: There Ain't No Such Thing as the Fastest Code</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: There Ain't No Such Thing as the Fastest Code</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="16" /> <meta name="chapter" content="16" />
<meta name="pages" content="313-316" /> <meta name="pages" content="313-316" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>Listing 16.6 OPT2.ASM</b></p><!-- CODE //--> <p><b>Listing 16.6 OPT2.ASM</b></p>
<pre> <pre>
; ;
; Opt2 Final optimization word count ; Opt2 Final optimization word count
@ -143,9 +136,9 @@
ret ret
_ScanBuffer endp _ScanBuffer endp
end end
</pre><!-- END CODE //--> </pre>
<h3><a id="Heading11"></a>Level 2: A New Perspective</h3> <h3 id="Heading11">Level 2: A New Perspective</h3>
<p>The second level of optimization is one of breaking out of the mode of thinking established by my original code. Some entrants clearly did exactly that. They stepped back, thought about what the code actually needed to do, rather than just improving how it already worked, and implemented code that sprang from that new perspective.</p> <p>The second level of optimization is one of breaking out of the mode of thinking established by my original code. Some entrants clearly did exactly that. They stepped back, thought about what the code actually needed to do, rather than just improving how it already worked, and implemented code that sprang from that new perspective.</p>
@ -176,10 +169,6 @@
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="17" /> <meta name="chapter" content="17" />
<meta name="pages" content="325-329" /> <meta name="pages" content="325-329" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 17.1 L17-1.CPP</b></p><!-- CODE //--> <p><b>LISTING 17.1 L17-1.CPP</b></p>
<pre> <pre>
/* C++ Game of Life implementation for any mode for which mode set /* C++ Game of Life implementation for any mode for which mode set
and draw pixel functions can be provided. and draw pixel functions can be provided.
@ -233,9 +226,9 @@ void cellmap::next_generation(cellmap&amp; next_map)
} }
} }
} }
</pre><!-- END CODE //--> </pre>
<p><b>LISTING 17.2 L17-2.CPP</b></p><!-- CODE //--> <p><b>LISTING 17.2 L17-2.CPP</b></p>
<pre> <pre>
/* VGA mode 13h functions for Game of Life. /* VGA mode 13h functions for Game of Life.
Tested with Borland C++. */ Tested with Borland C++. */
@ -293,7 +286,7 @@ void show_text(int x, int y, char *text)
gotoxy(TEXT_X_OFFSET + x, y); gotoxy(TEXT_X_OFFSET + x, y);
puts(text); puts(text);
} }
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -312,10 +305,6 @@ void show_text(int x, int y, char *text)
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="17" /> <meta name="chapter" content="17" />
<meta name="pages" content="340-345" /> <meta name="pages" content="340-345" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -37,7 +30,7 @@
<p><br /></p> <p><br /></p>
<p><b>LISTING 17.5 L17-5.CPP</b></p><!-- CODE //--> <p><b>LISTING 17.5 L17-5.CPP</b></p>
<pre> <pre>
/* C++ Game of Life implementation for any mode for which mode set /* C++ Game of Life implementation for any mode for which mode set
and draw pixel functions can be provided. The cellmap stores the and draw pixel functions can be provided. The cellmap stores the
@ -312,7 +305,7 @@ void cellmap::init()
} }
} while (&mdash;init_length); } while (&mdash;init_length);
} }
</pre><!-- END CODE //--> </pre>
<p><br /></p> <p><br /></p>
@ -331,10 +324,6 @@ void cellmap::init()
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" /> <meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" /> <meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title><!-- HEADER --> <title>Michael Abrash's Graphics Programming Black Book Special Edition: The Game of Life</title>
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<meta name="chapter" content="17" /> <meta name="chapter" content="17" />
<meta name="pages" content="345-346" /> <meta name="pages" content="345-346" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head> </head>
<body> <body>
@ -55,7 +48,7 @@
<p>No doubt we could get another two to five times improvement with good assembly code&mdash;but that&rsquo;s dwarfed by a 30-times improvement, so optimization at a conceptual level <i>must</i> come first.</p> <p>No doubt we could get another two to five times improvement with good assembly code&mdash;but that&rsquo;s dwarfed by a 30-times improvement, so optimization at a conceptual level <i>must</i> come first.</p>
<h4 align="left"><a id="Heading11"></a>The Challenge That Ate My Life</h4> <h4 align="left" id="Heading11">The Challenge That Ate My Life</h4>
<p>The most recent optimization challenge I laid my community of readers was to write the fastest possible Game of Life generation engine. By &ldquo;engine&rdquo; I meant that I didn&rsquo;t care about time spent in input or output, only time consumed by the call to <b>next-generation.</b> The time spent updating the cellmap was what I wanted people to concentrate on.</p> <p>The most recent optimization challenge I laid my community of readers was to write the fastest possible Game of Life generation engine. By &ldquo;engine&rdquo; I meant that I didn&rsquo;t care about time spent in input or output, only time consumed by the call to <b>next-generation.</b> The time spent updating the cellmap was what I wanted people to concentrate on.</p>
@ -96,10 +89,6 @@
<div align="center"> <div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed --> </div>
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more