[Coco] assembly question

William Astle lost at l-w.ca
Sat Aug 8 23:53:08 EDT 2015


DEC doesn't set C (carry) so any branch that relies on the setting of C 
cannot be used meaningfully after DEC. That is the four "unsigned" 
branches. DEC does, however, set N, Z, and V which means the signed 
branches (which don't test C) do work as expected (since they use V, not C).

The reason INC and DEC do not affect C is so that they can be used for 
iteration counting in multiple precision arithmetic.

On 2015-08-08 21:32, K. Pruitt wrote:
> I have an assembly question.
>
> How is the BCC operand any different than the BGE operand in the context
> of using it on a counter?
>
> Here's the code example:
>
>               ldb  #$03
> Loop      stb Counter
>
>               <do stuff here>
>
>               decb
>               bcc Loop
>
> The idea is to take the counter from 3 to 0 and include 0 in the loop.
> So four times through the loop.
>
> The code above does not work for me.  However, this code does:
>
>               ldb  #$03
> Loop      stb Counter
>
>               <do stuff here>
>
>               decb
>               bge Loop
>
> The only difference is the bge instead of the bcc. From the description
> I read in Leventhal's book, bcc and bge sound functionally identical in
> this context.
> But they are not.
>
>
>



More information about the Coco mailing list