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

Steve Lenham steve at bendentech.co.uk
Fri Mar 10 11:34:02 CET 2017

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!


Steve L.

More information about the Synth-diy mailing list