[Coco] dwwrite suggestion

Darren A mechacoco at gmail.com
Wed Dec 25 14:04:41 EST 2013


On Wed, Dec 25, 2013 at 11:40 AM, Robert Gault  wrote:

> Someone recently posted a problem with dwwrite and the random loss of bits
> under certain conditions. I lost the message so don't know who that was.
>
> Well I've been seeing intermittent problems that might have been caused by
> the above so looked at the code.
>
> This for "57600 (115200) bps using 6309 native mode".
> tx0020    bita      #1                  ; even or odd bit number ?
>           beq       tx0040              ; branch if even (15 cycles)
> tx0030    nop                           ; extra (16th) cycle
> tx0040    stb       -1,u                ; send bit
>
> Why should a positive bit require more time than a zero? In any case, nop
> is 2 cycles not 1. This ought to result in random speed and that does not
> seem right.
>
> Anyway I changed to code to
> tx0020    bita      #1                  ; even or odd bit number ?
>           beq       tx0040              ; now cycle count is the same
> tx0030    equ       *                   ; with or without a branch
> tx0040    nop
>           stb       -1,u
>
> Actually the bita and beq could be replaced by two more nop with the same
> cycle count.
>
> Well this version of dwwrite works fine on my Coco3 6309 system and at
> first glance seems to have removed some intermittent problems I was seeing.
> The bita #1 test does not seem to be needed.
>


I do NOT recommend this change.

The code above is for 6309 native mode.  A NOP instruction is only 1 cycle
in native mode, not 2.

The BITA instruction is not testing the bit value, but the rather the bit
number.  This causes the cycles-per-bit to alternate between 15 and 16
cycles (not random).  The reason for the alternating bit timing is because
at 57600 bps, there are 15.536 cycles per bit (894886.25 divided by 57600).
Without the alternating bit timing, the code will drift too far from the
ideal sampling point.

Darren



More information about the Coco mailing list