<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Define: overthinking</title>
	<atom:link href="http://www.coranac.com/2008/08/define-overthinking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coranac.com/2008/08/define-overthinking/</link>
	<description>my own little world</description>
	<lastBuildDate>Fri, 23 Dec 2011 16:50:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
	<item>
		<title>By: cearn</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/comment-page-1/#comment-1921</link>
		<dc:creator>cearn</dc:creator>
		<pubDate>Fri, 05 Sep 2008 10:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.coranac.com/?p=55#comment-1921</guid>
		<description>Yeah, the sanitizer&#039;s a bit of a bitch. It&#039;s a battle between the standard WP styles, my own styles and several plugins. I&#039;ve been toying with some of the settings to make sure the comments behave as sensible as possible, but as you can see it can still be a little messy. I can fix the code for you, but I&#039;d need the stuff that was deleted.

The code blocks are done with &lt;a href=&quot;http://blog.hackerforhire.org/code-snippet/&quot; rel=&quot;nofollow&quot;&gt;code snippet&lt;/a&gt;, which uses geshi and &#091;code&#093; tags. For pretty colors, you can use &lt;i&gt;lang=&quot;...&quot;&lt;/i&gt;; &lt;i&gt;cpp&lt;/i&gt; for C/C++ and &lt;i&gt;gccarm&lt;/i&gt; for ARM assembly are the most common for me.

I&#039;d love to have a preview, but my webscript-fu is still somewhat weak, so I&#039;m not sure how to implement it ... yet. Of course, if one should suddenly find itself in my mailbox, I would consider it (hint, hint).</description>
		<content:encoded><![CDATA[<p>Yeah, the sanitizer&#8217;s a bit of a bitch. It&#8217;s a battle between the standard WP styles, my own styles and several plugins. I&#8217;ve been toying with some of the settings to make sure the comments behave as sensible as possible, but as you can see it can still be a little messy. I can fix the code for you, but I&#8217;d need the stuff that was deleted.</p>
<p> The code blocks are done with <a href="http://blog.hackerforhire.org/code-snippet/" rel="nofollow">code snippet</a>, which uses geshi and &#91;code&#93; tags. For pretty colors, you can use <i>lang=&#8221;&#8230;&#8221;</i>; <i>cpp</i> for C/C++ and <i>gccarm</i> for ARM assembly are the most common for me.</p>
<p> I&#8217;d love to have a preview, but my webscript-fu is still somewhat weak, so I&#8217;m not sure how to implement it &#8230; yet. Of course, if one should suddenly find itself in my mailbox, I would consider it (hint, hint).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cydrak</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/comment-page-1/#comment-1920</link>
		<dc:creator>Cydrak</dc:creator>
		<pubDate>Fri, 05 Sep 2008 10:08:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.coranac.com/?p=55#comment-1920</guid>
		<description>Erk! Maimed by the sanitizer. It actually even ate a few lines. Sorry about that. :(

You&#039;ve got those beautiful code blocks up there--now I have to go reading... Is there a good reference on what Wordpress will tolerate? Or at least a well-hidden preview? ^_^;</description>
		<content:encoded><![CDATA[<p>Erk! Maimed by the sanitizer. It actually even ate a few lines. Sorry about that. :(</p>
<p> You&#8217;ve got those beautiful code blocks up there&#8211;now I have to go reading&#8230; Is there a good reference on what WordPress will tolerate? Or at least a well-hidden preview? ^_^;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cydrak</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/comment-page-1/#comment-1919</link>
		<dc:creator>Cydrak</dc:creator>
		<pubDate>Fri, 05 Sep 2008 10:01:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.coranac.com/?p=55#comment-1919</guid>
		<description>&lt;blockquote&gt;Don&#039;t you just love that barrel shifter? ^_^.&lt;/blockquote&gt;
I feel so weird working with x86 anymore! I guess it&#039;s partly a matter of perspective. (e.g.: Memory operands and register renaming as a form of code compression..)

6502 is my second favorite to ARM. Didn&#039;t try much, but I always found the simplicity refreshing. Though a funny thing about it is that if you set the low two opcode bits, supposedly you get an &quot;ALU + shifter&quot; op, like ORA + ASL (&quot;ASO&quot;). Sound familiar? These are the &quot;illegal&quot; ops the chip is so infamous for. I couldn&#039;t say whether that&#039;s where ARM got the idea, but it&#039;s very nifty indeed.

&lt;blockquote&gt;And now I&#039;m curious about that whole thing too, but I&#039;m fighting the urge to ask for details.&lt;/blockquote&gt;
Er, I&#039;ll try to be brief then. (It&#039;s not my strong point.)

Some background: Yamaha&#039;s OPL2/3 series cropped up in tons of 1990s-era sound boards. So many, that I wonder if lame OPL instruments are THE reason some folks associate MIDI with &quot;crap music.&quot; But used on children of the 80&#039;s, good &quot;FM&quot; tunes--like the NES and C64--should induce spine-shivering waves of nostalgia. ;-)

Other excuses include a burning curiosity regarding MAME&#039;s spaghettiesque OPL driver (from which I got the algorithms), and a nice, complete set of instrument patches (ah, wasted youth!).
&lt;pre&gt;
while(numSamples--) {
    // Envelopes (among other settings) modulate the wave amplitude.    
    if((envTimer0 -= dt) &lt; 0) updateEnv0();  // Branchy state machine
    if((envTimer1 -= dt) &gt;N] wraps properly.	
    feedb   = out0 + out0_pr;
    out0_pr = out0;             // wave0 can modulate its own phase.
    
    // wave0 modulates wave1 phase (or can just be mixed--not shown)	
    // note: amp and wave tables use log values (hence the adds).
    out0    = wave0[ (phase0 + (feedb &lt;&gt; F_BITS ];
    out0    = expTable[ amp0 + out0 ];
    out1    = wave1[ (phase1 + (out0  &lt;&gt; F_BITS ];
    out1    = expTable[ amp1 + out1 ];
    
    *pMix++ += out1;  // 32 bits (clamping and dither done later)	
}&lt;/pre&gt;
This is pseudocode for the meat of it. As you can see, it&#039;s not truly FM, but it&#039;s close. Topping out (at 18 voices, 32Khz stereo) uses ~75% of the ARM9.

Right now it&#039;s playing MIDIs, but I&#039;d love to see a Mario Paint sorta thing...
</description>
		<content:encoded><![CDATA[<blockquote><p>Don&#8217;t you just love that barrel shifter? ^_^.</p></blockquote>
<p> I feel so weird working with x86 anymore! I guess it&#8217;s partly a matter of perspective. (e.g.: Memory operands and register renaming as a form of code compression..)</p>
<p> 6502 is my second favorite to ARM. Didn&#8217;t try much, but I always found the simplicity refreshing. Though a funny thing about it is that if you set the low two opcode bits, supposedly you get an &#8220;ALU + shifter&#8221; op, like ORA + ASL (&#8220;ASO&#8221;). Sound familiar? These are the &#8220;illegal&#8221; ops the chip is so infamous for. I couldn&#8217;t say whether that&#8217;s where ARM got the idea, but it&#8217;s very nifty indeed.</p>
<blockquote><p>And now I&#8217;m curious about that whole thing too, but I&#8217;m fighting the urge to ask for details.</p></blockquote>
<p> Er, I&#8217;ll try to be brief then. (It&#8217;s not my strong point.)</p>
<p> Some background: Yamaha&#8217;s OPL2/3 series cropped up in tons of 1990s-era sound boards. So many, that I wonder if lame OPL instruments are THE reason some folks associate MIDI with &#8220;crap music.&#8221; But used on children of the 80&#8242;s, good &#8220;FM&#8221; tunes&#8211;like the NES and C64&#8211;should induce spine-shivering waves of nostalgia. ;-)</p>
<p> Other excuses include a burning curiosity regarding MAME&#8217;s spaghettiesque OPL driver (from which I got the algorithms), and a nice, complete set of instrument patches (ah, wasted youth!).</p>
<pre>
 while(numSamples--) {
     // Envelopes (among other settings) modulate the wave amplitude.
     if((envTimer0 -= dt) &lt; 0) updateEnv0();  // Branchy state machine
     if((envTimer1 -= dt) &gt;N] wraps properly.
     feedb   = out0 + out0_pr;
     out0_pr = out0;             // wave0 can modulate its own phase.

     // wave0 modulates wave1 phase (or can just be mixed--not shown)
     // note: amp and wave tables use log values (hence the adds).
     out0    = wave0[ (phase0 + (feedb &lt;&gt; F_BITS ];
     out0    = expTable[ amp0 + out0 ];
     out1    = wave1[ (phase1 + (out0  &lt;&gt; F_BITS ];
     out1    = expTable[ amp1 + out1 ];

     *pMix++ += out1;  // 32 bits (clamping and dither done later)
 }</pre>
<p> This is pseudocode for the meat of it. As you can see, it&#8217;s not truly FM, but it&#8217;s close. Topping out (at 18 voices, 32Khz stereo) uses ~75% of the ARM9.</p>
<p> Right now it&#8217;s playing MIDIs, but I&#8217;d love to see a Mario Paint sorta thing&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cearn</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/comment-page-1/#comment-1897</link>
		<dc:creator>cearn</dc:creator>
		<pubDate>Fri, 29 Aug 2008 14:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.coranac.com/?p=55#comment-1897</guid>
		<description>&lt;blockquote&gt;
[code]
mov timers, timer_1
orr timers, timer_2, lsl #16
mov r0, shiftCount
orr r0, someSpareFlags, lsl #8
orr r0, counter, lsl #12
...
loop:
rsbs timers, dt, timers, ror #16 ; decrement and test high half &lt; 0
blt infrequent_complex_event_1
rsbs timers, dt, timers, ror #16 ; decrement and test low half &lt; 0
blt pesky_distraction_2
...
mov foo, bar, lsl r0 ; uses low 8 bits of r0
...
orr/bic../tsts r0, someBit ; toy with spare flags
...
subs r0, #(1&lt;&lt;12) ; decrement and test counter
blt loop
[/code]&lt;/blockquote&gt;
Niiiice. I never had to cram several variables in a single word like you&#039;re doing for &lt;code&gt;r0&lt;/code&gt; here, but I&#039;ve always been fond of abusing ROR. For example, on some occasions you can split a coordinate into the divident and the modulo by using ROR 3 instead of LSR 3. In later instructions you can use either part with further shifts, usually without getting into trouble. 

I also came across a nice bit for the tail-end of a large fill routine. When you&#039;re down to less than 32 bytes, you can do a word-loop, unroll the word-loop, or go for a nifty &lt;code&gt;stm&lt;/code&gt;variant like this:
[code lang=&quot;gccarm&quot;]
	@ Assume r0:dst ; r3-r7:fill ; r2:remaining bytes
	tst		r2, #16
	stmneia	r0!, {r4-r7}
	tst		r2, #8
	stmneia	r0!, {r4-r5}
	tst		r2, #4
	... etc
[/code]
But you can actually test two bits at once if you shift them into the sign and carry bit:

[code lang=&quot;gccarm&quot;]
	@ Assume r0:dst ; r3-r7:fill ; r2:remaining bytes
	mov		ip, r2, lsl #(32-4)		@ test for bits 4 and 3
	stmcsia	r0!, {r4-r7}
	stmmiia	r0!, {r4-r5}
	mov		ip, r2, lsl #(32-2)		@ test for bits 2 and 1
	stmcsia	r0!, {r4}
	strmih	r4, [r0], #2
[/code]
Don&#039;t you just love that barrel shifter? ^_^.

&lt;blockquote&gt;This came from some Adlib/OPL2 emulation. Desparate enough? Well, that wasn&#039;t the end of it, and there are _still_ LDM&#039;s in there for lack of registers. Though not all of this was used in the end. I ditched sample-accurate envelopes, and I still can&#039;t break ~80 ARM9 cycles/sample. :&#124;
&lt;/blockquote&gt;
And now I&#039;m curious about that whole thing too, but I&#039;m fighting the urge to ask for details.</description>
		<content:encoded><![CDATA[<blockquote>
<div class="none">
<div class="none proglist" style=" ">mov timers, timer_1<br /> orr timers, timer_2, lsl <span class="co2">#16</span><br /> mov r0, shiftCount<br /> orr r0, someSpareFlags, lsl <span class="co2">#8</span><br /> orr r0, counter, lsl <span class="co2">#12</span><br /> &#8230;<br /> loop:<br /> rsbs timers, dt, timers, ror <span class="co2">#16 ; decrement and test high half &lt; 0</span><br /> blt infrequent_complex_event_1<br /> rsbs timers, dt, timers, ror <span class="co2">#16 ; decrement and test low half &lt; 0</span><br /> blt pesky_distraction_2<br /> &#8230;<br /> mov foo, bar, lsl r0 ; uses low <span class="nu0">8</span> bits of r0<br /> &#8230;<br /> orr/bic../tsts r0, someBit ; toy with spare flags<br /> &#8230;<br /> subs r0, <span class="co2">#(1&lt;&lt;12) ; decrement and test counter</span><br /> blt loop</div>
</div>
</blockquote>
<p> Niiiice. I never had to cram several variables in a single word like you&#8217;re doing for <code>r0</code> here, but I&#8217;ve always been fond of abusing ROR. For example, on some occasions you can split a coordinate into the divident and the modulo by using ROR 3 instead of LSR 3. In later instructions you can use either part with further shifts, usually without getting into trouble. </p>
<p> I also came across a nice bit for the tail-end of a large fill routine. When you&#8217;re down to less than 32 bytes, you can do a word-loop, unroll the word-loop, or go for a nifty <code>stm</code>variant like this:</p>
<div class="gccarm">
<div class="gccarm proglist" style=" ">&nbsp; &nbsp; <span class="co1">@ Assume r0:dst ; r3-r7:fill ; r2:remaining bytes</span><br /> &nbsp; &nbsp; <span class="re1">tst</span> &nbsp; &nbsp; <span class="kw2">r2</span>, #<span class="nu0">16</span><br /> &nbsp; &nbsp; <span class="re2">stmneia</span> <span class="kw2">r0</span>!, {r4-<span class="kw2">r7</span>}<br /> &nbsp; &nbsp; <span class="re1">tst</span> &nbsp; &nbsp; <span class="kw2">r2</span>, #<span class="nu0">8</span><br /> &nbsp; &nbsp; <span class="re2">stmneia</span> <span class="kw2">r0</span>!, {r4-<span class="kw2">r5</span>}<br /> &nbsp; &nbsp; <span class="re1">tst</span> &nbsp; &nbsp; <span class="kw2">r2</span>, #<span class="nu0">4</span><br /> &nbsp; &nbsp; &#8230; etc</div>
</div>
<p> But you can actually test two bits at once if you shift them into the sign and carry bit:</p>
<div class="gccarm">
<div class="gccarm proglist" style=" ">&nbsp; &nbsp; <span class="co1">@ Assume r0:dst ; r3-r7:fill ; r2:remaining bytes</span><br /> &nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">ip</span>, <span class="kw2">r2</span>, <span class="kw1">lsl</span> #(<span class="nu0">32</span>-<span class="nu0">4</span>) &nbsp; &nbsp; <span class="co1">@ test for bits 4 and 3</span><br /> &nbsp; &nbsp; <span class="re2">stmcsia</span> <span class="kw2">r0</span>!, {r4-<span class="kw2">r7</span>}<br /> &nbsp; &nbsp; <span class="re2">stmmiia</span> <span class="kw2">r0</span>!, {r4-<span class="kw2">r5</span>}<br /> &nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">ip</span>, <span class="kw2">r2</span>, <span class="kw1">lsl</span> #(<span class="nu0">32</span>-<span class="nu0">2</span>) &nbsp; &nbsp; <span class="co1">@ test for bits 2 and 1</span><br /> &nbsp; &nbsp; <span class="re2">stmcsia</span> <span class="kw2">r0</span>!, {<span class="kw2">r4</span>}<br /> &nbsp; &nbsp; <span class="re2">strmih</span>&nbsp; <span class="kw2">r4</span>, [<span class="kw2">r0</span>], #<span class="nu0">2</span></div>
</div>
<p> Don&#8217;t you just love that barrel shifter? ^_^.</p>
<blockquote><p>This came from some Adlib/OPL2 emulation. Desparate enough? Well, that wasn&#8217;t the end of it, and there are _still_ LDM&#8217;s in there for lack of registers. Though not all of this was used in the end. I ditched sample-accurate envelopes, and I still can&#8217;t break ~80 ARM9 cycles/sample. :|
 </p></blockquote>
<p> And now I&#8217;m curious about that whole thing too, but I&#8217;m fighting the urge to ask for details.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cydrak</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/comment-page-1/#comment-1895</link>
		<dc:creator>Cydrak</dc:creator>
		<pubDate>Mon, 25 Aug 2008 17:37:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.coranac.com/?p=55#comment-1895</guid>
		<description>Ahh, _that_ habit. Very insidious and captivating. And the death of many perfectly good evenings. Did I mention this post is giving me brainfaults? @_@

In the spirit of Not Helping(tm), I&#039;ll throw in my favorite ARM perversions:

mov timers, timer_1
orr timers, timer_2, lsl #16
mov r0, shiftCount
orr r0, someSpareFlags, lsl #8
orr r0, counter, lsl #12
...
loop:
    rsbs timers, dt, timers, ror #16  ; decrement and test high half &lt; 0
    blt  infrequent_complex_event_1
    rsbs timers, dt, timers, ror #16  ; decrement and test low half &lt; 0
    blt  pesky_distraction_2
    ...
    mov  foo, bar, lsl r0             ; uses low 8 bits of r0
    ...
    orr/bic../tsts r0, someBit        ; toy with spare flags
    ...
    subs r0, #(1&lt;&lt;12)                 ; decrement and test counter
    blt loop

This came from some Adlib/OPL2 emulation. Desparate enough? Well, that wasn&#039;t the end of it, and there are _still_ LDM&#039;s in there for lack of registers. Though not all of this was used in the end. I ditched sample-accurate envelopes, and I still can&#039;t break ~80 ARM9 cycles/sample. :&#124;</description>
		<content:encoded><![CDATA[<p>Ahh, _that_ habit. Very insidious and captivating. And the death of many perfectly good evenings. Did I mention this post is giving me brainfaults? @_@</p>
<p> In the spirit of Not Helping(tm), I&#8217;ll throw in my favorite ARM perversions:</p>
<p> mov timers, timer_1<br />
 orr timers, timer_2, lsl #16<br />
 mov r0, shiftCount<br />
 orr r0, someSpareFlags, lsl #8<br />
 orr r0, counter, lsl #12<br />
 &#8230;<br />
 loop:<br />
     rsbs timers, dt, timers, ror #16  ; decrement and test high half &lt; 0<br />
     blt  infrequent_complex_event_1<br />
     rsbs timers, dt, timers, ror #16  ; decrement and test low half &lt; 0<br />
     blt  pesky_distraction_2<br />
     &#8230;<br />
     mov  foo, bar, lsl r0             ; uses low 8 bits of r0<br />
     &#8230;<br />
     orr/bic../tsts r0, someBit        ; toy with spare flags<br />
     &#8230;<br />
     subs r0, #(1&lt;&lt;12)                 ; decrement and test counter<br />
     blt loop</p>
<p> This came from some Adlib/OPL2 emulation. Desparate enough? Well, that wasn&#8217;t the end of it, and there are _still_ LDM&#8217;s in there for lack of registers. Though not all of this was used in the end. I ditched sample-accurate envelopes, and I still can&#8217;t break ~80 ARM9 cycles/sample. :|</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!--
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
</head>
<body>
<p>
My database has called in sick. Please imagine some 
annoying elevator tune till he gets back.
</p>
<p>
<small>[[Doo-di-doo tooo. Dum-di-dum-di-doo-dooo.]]</small>
</p>
</body>
</html>

-->
