[Coco] assembly question

Arthur Flexser flexser at fiu.edu
Sun Aug 9 16:44:16 EDT 2015


I always found it much clearer to use the mnemonic BLO rather than BCS
(both are equivalent, opcode $25), and BHS rather than BCC (both opcode
$24).  Makes the outcome less likely to be unexpected.

Art

On Sun, Aug 9, 2015 at 4:30 PM, camillus <camillus.b.58 at gmail.com> wrote:

> hi my $0.02 worth.
>
> I looked up in the 6809 instructions and DEC B (A) does not change the
> carrybit.
>
> Also the BCC and/or BGE are testing the carry bit, not the value of the
> counter in B.
>
> BCC ( Branch if Carry Clear ) will only branch when the carry is 0.
>
> BGE ( Branch Greater or Equal to zero ) which will always branch because
> it is either 1 ( greater then 0 ) or 0 ( equal with zero )
>
> So to make this work I would test the content in B with COMB, #0 which
> will set carrybit when true and then BNE ( Branch Not Equal to zero ) as
> next instruction, ofcource needs to branch out of the loop in this case.
>  So if you really want to have 4 itterations 0-3 then you have to start at
> 4 because zero would take u out.
>
> The reason that you exit the loop, I think is because the counter B goes
> down to zero, and I do not know if it can go negative. My guess is that
> somehow the carry get set by the fact B try's to go lower then zero.
>
> Do not take this info as the holy grail, it was just my thoughts, and I am
> just human, prone to error or mistakes...lol
>
>
>
> cb
>
> Sent from Mailbird [
> http://www.getmailbird.com/?utm_source=Mailbird&utm_medium=email&utm_campaign=sent-from-mailbird
> ]
> On 8/9/2015 5:59:45 AM, Barry Nelson <barry.nelson at amobiledevice.com>
> wrote:
> 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
> > To: coco at maltedmedia.com
> > Subject: Re: [Coco] assembly question
> > Message-ID:
> > 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
> >>
> >>
> >>
> >> 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
> >>
> >>
> >>
> >> 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
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list