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

Darren A mechacoco at gmail.com
Sat Sep 16 01:17:09 EDT 2017


On Fri, Sep 15, 2017 at 8: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/
> >
>
>

In your first unrolled loop example, you could have saved a fair amount of
time by not using the auto-increment index mode.  You only need to
increment X once per loop using ABX.  The ,X++ adds 3 cycles to the base
count.  Using 5-bit displacements (-16 to +14) keeps the code size small
and only adds 1 cycle to the base count. You will also have one occurrence
of ,X which adds nothing.

    LDX    #$4000+16
    LDU    #$0000
    LDD    #$0020

!   STU    -16,X
    STU    -14,X
    STU    -12,X
    STU    -10,X
    STU    -8,X
    STU    -6,X
    STU    -4,X
    STU    -2,X
    STU    ,X
    STU    2,X
    STU    4,X
    STU    6,X
    STU    8,X
    STU    10,X
    STU    12,X
    STU    14,X
    ABX
    DECA
    BNE    <


- Darren


More information about the Coco mailing list