[Coco] assembly question

K. Pruitt pruittk at roadrunner.com
Sun Aug 9 07:43:31 EDT 2015


So the carry flag is being set, inadvertently in this case, by

            eora  -5,x                   ; get changed bits from Ctrl Reg
            suba  #$60                ; did expected bits change?

both of these lines?

If I understand it correctly, math and logic operands effect the carry flag?

So at some point in the loop the carry flag is set by one or both of the 
instructions and at that point a exit from the loop is achieved?



----- Original Message ----- 
From: "K. Pruitt"
Sent: Sunday, August 09, 2015 4:06 AM
Subject: Re: [Coco] assembly question


> 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"
> 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 Subject: Re: [Coco] assembly question
>>>
>>> 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