<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: rforth1 optimizations</title>
	<link>http://www.rfc1149.net/blog/2006/10/24/rforth1-optimizations/</link>
	<description>Samuel Tardieu's dual-sided blog</description>
	<pubDate>Fri, 25 Jul 2008 12:51:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Samuel Tardieu</title>
		<link>http://www.rfc1149.net/blog/2006/10/24/rforth1-optimizations/#comment-12993</link>
		<dc:creator>Samuel Tardieu</dc:creator>
		<pubDate>Tue, 24 Oct 2006 09:44:52 +0000</pubDate>
		<guid>http://www.rfc1149.net/blog/2006/10/24/rforth1-optimizations/#comment-12993</guid>
		<description>&lt;b&gt;Pierre:&lt;/b&gt; of course. Just declare your leds in a temporary variable (think "double buffering"):

&lt;pre&gt;
cvariable double-buffer
double-buffer 5 bit led0
double-buffer 6 bit led1
double-buffer 7 bit led2
&lt;/pre&gt;

then define a word to apply the changes made in the double buffer:

&lt;pre&gt;
: apply double-buffer c@ LATB c! ;
&lt;/pre&gt;

and call it in the mainloop:

&lt;pre&gt;
: mainloop ( -- ) begin switch-led0 apply 100ms again ;
&lt;/pre&gt;

The generated code for this change only adds one instruction in the main loop:

&lt;pre&gt;
; init_runtime: defined at lib/primitives.fs:3
init_runtime
	movlb 1
	clrf double_buffer,1

; main: defined at example.fs:28
main
	movlw 0x84
	movwf T0CON,0
	clrf LATB,0
	movlw 0x1f
	movwf TRISB,0
_lbl___221
	btg double_buffer,5,1
	btfsc double_buffer,5,1
	bra _lbl___222
	btg double_buffer,6,1
	btfss double_buffer,6,1
	btg double_buffer,7,1
_lbl___222
	movff double_buffer,LATB
	movlw LOW(-31250)
	movwf TMR0L,0
	movlw HIGH(-31250)
	movwf (TMR0L+1),0
	bcf INTCON,2,0
_lbl___224
	btfsc INTCON,2,0
	bra _lbl___221
	bra _lbl___224

double_buffer equ 0x100
&lt;/pre&gt;

Also note that since RAM is being used, an intialization of BSR (using "movlb 1") has been done to allow faster access through the BSR.</description>
		<content:encoded><![CDATA[<p><b>Pierre:</b> of course. Just declare your leds in a temporary variable (think &#8220;double buffering&#8221;):</p>
<pre>
cvariable double-buffer
double-buffer 5 bit led0
double-buffer 6 bit led1
double-buffer 7 bit led2
</pre>
<p>then define a word to apply the changes made in the double buffer:</p>
<pre>
: apply double-buffer c@ LATB c! ;
</pre>
<p>and call it in the mainloop:</p>
<pre>
: mainloop ( -- ) begin switch-led0 apply 100ms again ;
</pre>
<p>The generated code for this change only adds one instruction in the main loop:</p>
<pre>
; init_runtime: defined at lib/primitives.fs:3
init_runtime
	movlb 1
	clrf double_buffer,1

; main: defined at example.fs:28
main
	movlw 0x84
	movwf T0CON,0
	clrf LATB,0
	movlw 0x1f
	movwf TRISB,0
_lbl___221
	btg double_buffer,5,1
	btfsc double_buffer,5,1
	bra _lbl___222
	btg double_buffer,6,1
	btfss double_buffer,6,1
	btg double_buffer,7,1
_lbl___222
	movff double_buffer,LATB
	movlw LOW(-31250)
	movwf TMR0L,0
	movlw HIGH(-31250)
	movwf (TMR0L+1),0
	bcf INTCON,2,0
_lbl___224
	btfsc INTCON,2,0
	bra _lbl___221
	bra _lbl___224

double_buffer equ 0x100
</pre>
<p>Also note that since RAM is being used, an intialization of BSR (using &#8220;movlb 1&#8243;) has been done to allow faster access through the BSR.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre</title>
		<link>http://www.rfc1149.net/blog/2006/10/24/rforth1-optimizations/#comment-12985</link>
		<dc:creator>Pierre</dc:creator>
		<pubDate>Tue, 24 Oct 2006 08:27:31 +0000</pubDate>
		<guid>http://www.rfc1149.net/blog/2006/10/24/rforth1-optimizations/#comment-12985</guid>
		<description>Très très joli !

Est-il facile de réécrire le code pour que la commutation de plusieurs leds lors de la propagation de retenue ait lieu _exactement_ au même moment plutôt qu'une par une ? Genre, stocker le motif binaire dans une seule variable, et recopier la variable en question dans le registre juste avant l'appel de 100ms.</description>
		<content:encoded><![CDATA[<p>Très très joli !</p>
<p>Est-il facile de réécrire le code pour que la commutation de plusieurs leds lors de la propagation de retenue ait lieu _exactement_ au même moment plutôt qu&#8217;une par une ? Genre, stocker le motif binaire dans une seule variable, et recopier la variable en question dans le registre juste avant l&#8217;appel de 100ms.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
