Hi,
Before you enter the Interrupt Service Routine, you need to save the STATUS register since all registers get scrapped during the ISR (why is that, btw?).
To do this, you can use:
swapf STATUS, W ; move status to w without affecting Z bit
movwf STATUS_TEMP ; copy to RAM (with nibbles swapped);
Just wondering why swapf doesn't affect the Z bit, what if STATUS contained all 0's? Surely the Z bit would then go to 1 because the operation resulted in a register full of 0's?
Why couldn't you use this:
movf STATUS, W
movwf STATUS_TEMP
I don't understand how movf affects the Z bit, because the result of moving STATUS to W wouldn't be 0 unless STATUS contained all 0's right?
Hope you can clear this up for me!
Before you enter the Interrupt Service Routine, you need to save the STATUS register since all registers get scrapped during the ISR (why is that, btw?).
To do this, you can use:
swapf STATUS, W ; move status to w without affecting Z bit
movwf STATUS_TEMP ; copy to RAM (with nibbles swapped);
Just wondering why swapf doesn't affect the Z bit, what if STATUS contained all 0's? Surely the Z bit would then go to 1 because the operation resulted in a register full of 0's?
Why couldn't you use this:
movf STATUS, W
movwf STATUS_TEMP
I don't understand how movf affects the Z bit, because the result of moving STATUS to W wouldn't be 0 unless STATUS contained all 0's right?
Hope you can clear this up for me!