[sdiy] IIR Shift Filter problem - help with bug spotting in PIC ASM

rburnett at richieburnett.co.uk rburnett at richieburnett.co.uk
Fri Mar 10 12:10:36 CET 2017


Tom, can't you single-step through the good and bad code examples in 
MPLAB Simulator and then see where the bad code goes astray?  I know it 
is a bit of drag, but it's only doing a bit of arithmetic, so shouldn't 
be too difficult to keep track of what's going on in various registers?  
This is one of those problems where the simulator *should* be useful.

-Richie,


On 2017-03-10 10:34, Steve Lenham wrote:
> On 10/03/2017 09:59, Roman Sowa wrote:
>> It struck me this morning when I looked at it again.
>> 
>> You cannot xorwf the carry/borrow bit, that will never work.
>> Only clrc or setc can do that.
>> 
>> I'm talking about this part:
>> ======================================================
>> 
>>     ; Borrow is zero if result required borrow (negative result)
>>      ; Flip the state of the borrow flag
>>     movlw    0x01
>>     xorwf    STATUS, f        ; Borrow set if negative
>> =======================================================
> 
> I'm intrigued by this thread and, like Tom and much to my annoyance,
> cannot yet see the problem with the "bad" code.
> 
> However, I don't think it can be that. From a typical PIC datasheet:
> 
> "The STATUS register can be the destination for any
> instruction, like any other register. If the STATUS
> register is the destination for an instruction that affects
> the Z, DC or C bits, then the write to these three bits is
> disabled. These bits are set or cleared according to the
> device logic."
> 
> Neither MOVLW nor XORWF affect the carry/borrow bit, so modifying it
> in that way _should_ be fine.
> 
> Tom, you told us that the "bad" version isn't working, but in what
> way? Can you see what is actually happening to the values?
> 
> I hope somebody works it out, because I really want to know the answer 
> now!
> 
> Cheers,
> 
> Steve L.
> 
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy



More information about the Synth-diy mailing list