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

View file

@ -10,16 +10,9 @@
<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" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Zenning and the Flexible Mind</title><!-- HEADER -->
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Zenning and the Flexible Mind</title>
<meta name="chapter" content="22" />
<meta name="pages" content="413-417" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head>
<body>
@ -37,22 +30,22 @@
<p><br /></p>
<h2><a id="Heading1"></a>Chapter 22<br />
<h2 id="Heading1">Chapter 22<br />
Zenning and the Flexible Mind</h2>
<h3><a id="Heading2"></a>Taking a Spin through What You&rsquo;ve Learned</h3>
<h3 id="Heading2">Taking a Spin through What You&rsquo;ve Learned</h3>
<p>And so we come to the end of our journey; for now, at least. What follows is a modest bit of optimization, one which originally served to show readers of <i>Zen of Assembly Language</i> that they had learned more than just bits and pieces of knowledge; that they had also begun to learn how to apply the flexible mind&mdash;unconventional, broadly integrative thinking&mdash;to approaching high-level optimization at the algorithmic and program design levels. You, of course, need no such reassurance, having just spent 21 chapters learning about the flexible mind in many guises, but I think you&rsquo;ll find this example instructive nonetheless. Try to stay ahead as the level of optimization rises from instruction elimination to instruction substitution to more creative solutions that involve broader understanding and redesign. We&rsquo;ll start out by compacting individual instructions and bits of code, but by the end we&rsquo;ll come up with a solution that involves the very structure of the subroutine, with each instruction carefully integrated into a remarkably compact whole. It&rsquo;s a neat example of how optimization operates at many levels, some much less determininstic than others&mdash;and besides, it&rsquo;s just plain fun.</p>
<p>Enjoy!</p>
<h3><a id="Heading3"></a>Zenning</h3>
<h3 id="Heading3">Zenning</h3>
<p>In Jeff Duntemann&rsquo;s excellent book <i>Borland Pascal From Square One</i> (Random House, 1993), there&rsquo;s a small assembly subroutine that&rsquo;s designed to be called from a Turbo Pascal program in order to fill the screen or a systemscreen buffer with a specified character/attribute pair in text mode. This subroutine involves only 21 instructions and works perfectly well; however, with what we know, we can compact the subroutine tremendously and speed it up a bit as well. To coin a verb, we can &ldquo;Zen&rdquo; this already-tight assembly code to an astonishing degree. In the process, I hope you&rsquo;ll get a feel for how advanced your assembly skills have become.</p>
<p>Jeff&rsquo;s original code follows as Listing 22.1 (with some text converted to lowercase in order to match the style of this book), but the comments are mine.</p>
<p><b>LISTING 22.1 L22-1.ASM</b></p><!-- CODE //-->
<p><b>LISTING 22.1 L22-1.ASM</b></p>
<pre>
OnStack struc ;data that&rsquo;s stored on the stack after PUSH BP
OldBP dw ? ;caller&rsquo;s BP
@ -88,7 +81,7 @@ Bye:mov sp,bp ;restore original stack pointer
pop bp ; and caller&rsquo;s BP
ret EndMrk-RetAddr-2 ;return, clearing the parms from the stack
ClearS endp
</pre><!-- END CODE //-->
</pre>
<p>The first thing you&rsquo;ll notice about Listing 22.1 is that <b>ClearS</b> uses a <b>REP STOSW</b> instruction. That means that we&rsquo;re not going to improve performance by any great amount, no matter how clever we are. While we can eliminate some cycles, the bulk of the work in <b>ClearS</b> is done by that one repeated string instruction, and there&rsquo;s no way to improve on that.</p>
@ -115,10 +108,6 @@ ClearS endp
<div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</div>
</body>
</html>