[Coco] assembly question

James Ross jrosslist at outlook.com
Sun Aug 9 19:31:19 EDT 2015


Ah... looks like BPL and BGE could be used interchangeably in this scenario. 

Page 42 BGE Branch If Greater than or Equal to Zero

IF CC.N = CC.V Branch 

So back to the DEC:  

V The Overflow flag is set if the original value was 80 (8-bit) or 8000 (16-bit); cleared otherwise.

Looks like BGE will work reliably too since V is *always* going to be 0 in this case (unless you started w/ value $80 (-128) in B register)

----------------------------------------
> From: pruittk at roadrunner.com
> To: coco at maltedmedia.com
> Date: Sun, 9 Aug 2015 16:24:03 -0700
> Subject: Re: [Coco] assembly question
>
>
> ----- Original Message -----
> From: "camillus"
> Sent: Sunday, August 09, 2015 1:30 PM
> Subject: Re: [Coco] assembly question
>
>
>> 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
>>
>
> Yeah, I suggested the starting at 4 thing as well. You'll have to ask Barry
> if he rolled his eyes at my suggestion or not. Hehe.
>
> Internally the MPI's slot are numbered 0-3 and the value in B must follow
> the pattern of 3, 2, 1 and 0. If you start at 4 then the CoCo thinks you're
> telling it to access slot 5 of the MPI. I even rewrote the routine to run 2
> different counters... one for the loop and one to keep track of the MPI
> slot. It was absurd. Wasted about 45 minutes on it.
>
> The code initially had a BNE in place of the BGE. It looked like it should
> work, but in reality it never included zero in the loop as it bailed AT
> zero. And since zero corresponds to slot 1 of the MPI, if you had your
> CoCoSDC in slot 1 then the sdir, sdc and sdrive commands reported that it
> couldn't find the CoCoSDC.
>
> Barry suggested to me that BCC should work, and I agreed that it should. But
> it didn't work for me, so I tried the BGE instruction and it worked.
>
> Here is how I thought the BCC worked in this case: I thought that when the
> number went negative it would set the carry flag, thus allowing the loop to
> end. As it doesn't set the carry flag it was the wrong instruction for the
> task.
>
> BGE fits the logic of the loop and everything seems to work just fine in all
> 4 slots of the MPI now.
>
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
 		 	   		  


More information about the Coco mailing list