[Coco] Optimizing 6809 Assembly Code: Part 2 – Speedup Storing Data – Unrolling Loops

Dave Philipsen dave at davebiz.com
Sat Sep 16 22:37:19 EDT 2017


Haha! It's all Greek to me.

Dave

> On Sep 16, 2017, at 8:35 PM, Brett Gordon <beretta42 at gmail.com> wrote:
> 
> This is how literals (string,number,etc) are done in forth!
> 
> : slit  ( -- a ) \ string literal runtime.
> pull dup dup @ + push ;
> 
> So:
> 
> " Hello World!"
> 
> Compiles to this:
> 
> <slit> <12><H><e><l>...<next op>
> 
> : type  ( a -- ) \ print string
> dup cell+ swap @ for c at + emit next drop ;
> 
> Who needs registers anyway? :)
> 
> 
> 
>> On Sep 15, 2017 11:07 PM, "Dave Philipsen" <dave at davebiz.com> wrote:
>> 
>> Here's a little trick you could add to your blog.  I think I posted an
> example of this before.  I don't know that it necessarily optimizes for
> speed but it saves space. When printing a string or any kind of calling a
> subroutine which requires a string, instead of pointing to the string and
> then calling the subroutine like this:
>> 
>> ldx   #strptr         point to the string
>> jsr   prtstr          print the string
>> lda   #??             continue with the rest of the program
>> 
>> You can do this:
>> 
>> jsr   prtstr          call the print string subroutine which pulls the
> address of the string from the
>> fcs   /text string/   program counter which was just pushed to the stack
>> lda   #?? continue with the rest of the program
>> 
>> The prtstr routine can change the program counter as it is saved on the
> stack so that when the routine returns, it returns to the point just past
> the end of the string. This optimizes for size by eliminating the need to
> load the pointer each time you print. It also reduces complexity because
> you don't need to assign a label to the string.
>> 
>> 
>> 
>> 
>> 
>>> On 9/15/2017 9:44 PM, Glen Hewlett wrote:
>>> 
>>> Hi Again,
>>> 
>>> I just posted Part 2 of my series of blogs about optimizing 6809
> assembly language programs.
>>> 
>>> 
> https://nowhereman999.wordpress.com/2017/09/15/optimizing-6809-assembly-code-part-2-speedup-storing-data-unrolling-loops/
> <
> https://nowhereman999.wordpress.com/2017/09/15/optimizing-6809-assembly-code-part-2-speedup-storing-data-unrolling-loops/
>> 
>>> 
>>> Cheers,
>>> Glen
>>> 
>> 
>> 
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list