[Coco] assembly question

K. Pruitt pruittk at roadrunner.com
Sun Aug 9 07:06:29 EDT 2015


Yeah, how did it exit that loop? I haven't noticed any sort of timing 
difference that would indicate it was caught up in an extended loop 
previously.


----- Original Message ----- 
From: "Barry Nelson" <barry.nelson at amobiledevice.com>
To: <coco at maltedmedia.com>
Sent: Sunday, August 09, 2015 3:59 AM
Subject: Re: [Coco] assembly question


> Really? Arg. I just wrote some code using bcc and it seemed to work after 
> a decb, at least my code did not loop endlessly. I wonder how it managed 
> to exit my loop? Probably something else inside my loop is setting the 
> carry flag? I guess I had better use bge instead. Thanks for the info. 
> Darn code quirks! You are sure right?
>
> On Aug 9, 2015, at 1:18 AM, coco-request at maltedmedia.com wrote:
>
>> Date: Sat, 08 Aug 2015 21:53:08 -0600
>> From: William Astle <lost at l-w.ca>
>> To: coco at maltedmedia.com
>> Subject: Re: [Coco] assembly question
>> Message-ID: <55C6CEA4.6040008 at l-w.ca>
>> Content-Type: text/plain; charset=utf-8; format=flowed
>>
>> 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.
>
>
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
> 



More information about the Coco mailing list