[Coco] assembly question

K. Pruitt pruittk at roadrunner.com
Sun Aug 9 19:24:03 EDT 2015


----- 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.




More information about the Coco mailing list