Not quite; the original content of foo was 0x3F, so if the register foo was where STATUS was saved to with a file move instruction - MOVF as Exo claims, and then the SWAP instruction used to restore STATUS, STATUS now contains 0xF3, not 0x3F.
Some days, I'm not very eloquent.
I haven't looked back through the thread, but that sequence is used to restore the Wreg, so we would use:
(unfortunately the editor removes leading spaces, collapses intermediate sequences of spaces
into a single space, and doesn't allow 'tabs'; so this doesn't look at all as it would in a program)
Note; 'movf' affects the Zero flag in STATUS, whereas 'movwf' and 'swapf' do not.
; Save context:
movwf foo ; Saves Wreg in 'foo'
movf STATUS,w ; Copies STATUS reg unchanged into Wreg ..
; .. since although 'movf' affects the Zero flag in STATUS, this change ..
; .. does not happen until after the move into Wreg is done.
movwf boo ; .. and saves STATUS in 'boo'
;
; ---- Body of subroutine ----
;
; Restore context
movf boo,w ; Original value of STATUS into Wreg ..
movwf STATUS ; .. and into the STATUS reg, does not alter STATUS after move.
; Now we need to restore Wreg without using 'movf' ..
; .. which affects the Zero bit in the STATUS register.
swapf foo,f ; Original value of Wreg 'swapped' still in 'foo' ..
swapf foo,w ; .. and swapped again restoring Wreg original value.
I hope this helps
Best wishes, Harry