[Coco] Quick 6809 Q for night owls in the US

Johann Klasek johann+coco at klasek.at
Tue Apr 15 13:09:07 EDT 2014


On Tue, Apr 15, 2014 at 11:19:59PM +1000, Mark McDougall wrote:
> How would one write a (tight) loop, say a few thousand iterations in 6809 
> assembler? Can it be done with the X/Y registers? D? Or do I need a memory 
> variable? It's for a delay...

A stackbased variant (16-bit counter) without bounded to a special
register, initial count value passed on stack (modified, 0 on return) ...

; main
        ldd #$0101
        pshs d
        bsr delay
        leas 2,s
        ...
        rts

; delay loop without register
delay
        tst 3,s                 ; high adjustment for a zero flag cascaded loop
        beq nocorr
        inc 2,s                 ; correct high if low <> 0
nocorr

waitl   dec 3,s                 ; low
        bne waitl
        dec 2,s                 ; high
        bne waitl
        rts


Johann

-- 
The dragon on my side: http://klasek.at/hc/dragon/



More information about the Coco mailing list