> They key point here (and also what I *think* that Tamas > has got wrong) is that MOVWF does *not* change the Z-flag. Sorry I did not say that :-) I said MOVF changes the Z. Also said that as there are at least two flags in STATUS that are not writable and have no idea when and what circumstances both of them get cleared MOVF as saving the STATUS might work (as STATUS will never be completely zero). And also said :-) that I think it is safer to use SWAPF and there is no any reason not to use that. Tamas On Tue, Jul 1, 2008 at 6:43 PM, Jan-Erik Soderholm < jan-erik.soderholm@telia.com> wrote: > Rolf wrote: > > > ORG 0x004 ; interrupt vector location > > movwf w_temp ; save off current W register contents > > movf STATUS,w ; move status register into W register > > movwf status_temp ; save off contents of STATUS register > > > > They key point here (and also what I *think* that Tamas > has got wrong) is that MOVWF does *not* change the Z-flag. > It doesn't change any STATUS flags. Thats why the code > *does* work, even without any SWAPF's in the code above. > > Below, OTOH, SWAP *must* be used, since MOVF (either to "W" > or to "F") *does* set/clear the Z-flag. > > Jan-Erik. > > > > > > ; isr code can go here or be located as a call subroutine elsewhere > > > > > > movf status_temp,w ; retrieve copy of STATUS register > > movwf STATUS ; restore pre-isr STATUS register > > contents > > swapf w_temp,f > > swapf w_temp,w ; restore pre-isr W register contents > > retfie ; return from interrupt > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- Rudonix DoubleSaver http://www.rudonix.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist