Robin Abbott of Forest Electronic Developments says:
This might be of use to someone. Recently I had a project where a subroutine took a value in W and saved to a software stack:movwf Temp movfw sp ; Stack pointer movwf FSR ; Point to it movfw Temp movwf 0Trouble is it uses a temporary variable which I didn't have (it is in an interrupt). This alternative which makes use of XOR uses no temporary variable at the expense of 1 extra word:
movwf FSR movfw sp xorwf FSR xorwf FSR,w xorwf FSR movwf 0You can also use this to swap two variables (say x and y) without a temporary variable leaving X (or Y if order is reversed) in W.
movfw x ; Get X xorwf y ; Y is now X^Y xorwf y,w ; W is now (X^y)^X==Y (say OldY) movwf x ; Now X is OldY xorwf y ; finally Y is (OldX^Y)^Y==OldXI think this may be an old technique - I have vague memories of something similar from the pre-history of programming, but only found a use for