[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with confirmation on a small bit of assembly?
David Empson wrote:
> Tristan Mumford <xtristan.xmumford@xgmail.xcom> wrote:
>
>> David Empson wrote:
>>
>> > If it was SEC instead of CLC before the ADC then it would be adding one
>> > more. ADC adds the operand plus the carry flag to the accumulator.
>>
>> I see now. You have also made me think that I have to check for dropped
>> flags in other parts of my code. That could cause some nasty fencepost
>> errors.
>
> Yes, you have to watch out for the carry flag, and the lack of
> add/subtract without carry.
>
> Some other flag-related traps for young players (especially if familiar
> with other processors):
Sorry. I'll do a proper reply tomorrow. I'm exhausted.
Just thought you'd like to know I did find the bug. If I have the time I'll
fix it tomorrow. It was in that for...loop too.
After applying a liberal dose of printfs that spit out data to anything
which may be called around when it jams up I tracked it. It just sails on
past 0 and wraps around, spitting the contents of memory at the poor
SL811HS all through its memory map. Correct me of I'm wrong but even though
I was silly and used an unsigned 8 bit int, it still should have stopped at
0, right?
Although I do recall another bug with an older version of the compiler (CCSC
PIC C) which treated one of the 8 bit data types like it were boolean. Ie +
= OR, * = AND, etc etc. I had to sift through its generated assembler to
find that bug.
Anyway, proper reply tomorrow. Sorry. My lucidity has been used up for
today.
-snip... for now-
--
-----> http://members.dodo.com.au/~izabellion1/tristan/index.html <-----
===== It's not pretty, it's not great, but it is mine. =====