Helpful ReplyFlying with software and swapff macro

Author
SeanD
Super Member
  • Total Posts : 475
  • Reward points : 0
  • Joined: 2009/10/23 07:48:32
  • Location: Dark Rural Northumberland
  • Status: offline
2014/04/06 02:09:33 (permalink)
4 (1)

Flying with software and swapff macro

One of the most useful postson the forum was Stefan's flying with software
 
http://www.microchip.com/forums/m391727.aspx
 
I say was because most of the links do not work with the new forum upgrade. I was looking for a swapff macro -there was a neat solution without using a temp register which I can no longer find.
 
Does anyone have a copy? or even better can the admin fix the links as there is lots of great stuff potentially here.
 
Sean
#1
1and0
Access is Denied
  • Total Posts : 8337
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Flying with software and swapff macro 2014/04/06 09:20:26 (permalink) ☄ Helpfulby SeanD 2014/04/06 12:26:32
+5 (3)
SeanD
I was looking for a swapff macro -there was a neat solution without using a temp register which I can no longer find.  Does anyone have a copy?

Here's one:

;
; Swap fr1 with fr2 (fr1 <-> fr2)
;
swapff  macro   fr1,fr2
        movf    fr1,w       ;
        subwf   fr2,w       ; w = fr2 - fr1
        addwf   fr1,f       ; fr1 = fr1 + (fr2 - fr1)
        subwf   fr2,f       ; fr2 = fr2 - (fr2 - fr1)
        endm

<edit> Here's another:

;
; Swap fr1 with fr2 (fr1 <-> fr2)
;
swapff  macro   fr1,fr2
        movf    fr2,w       ;
        xorwf   fr1,w       ; w = fr1 ^ fr2
        xorwf   fr1,f       ; fr1 = fr1 ^ (fr1 ^ fr2)
        xorwf   fr2,f       ; fr2 = fr2 ^ (fr1 ^ fr2)
        endm

Here's one swapping WREG with a register:

;
; Swap w with fr (w <-> fr)
;
swapwf  macro   fr
        xorwf   fr,w        ; w  = fr ^ w
        xorwf   fr,f        ; fr = fr ^ (fr ^ w)
        xorwf   fr,w        ; w  = fr ^ (fr ^ w) ^ (fr ^ w)
        endm

post edited by 1and0 - 2014/04/06 09:34:50
#2
Ian.M
Super Member
  • Total Posts : 13114
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re: Flying with software and swapff macro 2014/04/06 11:11:08 (permalink) ☄ Helpfulby SeanD 2014/04/06 12:26:11
+4 (2)
The problem is mostly internal links to these forums. The actual message numbers haven't changed.   Copy the URL of the offending link and edit it to put  http://www.microchip.com/forums/FindPost/ before the message number and nothing after it.
#3
1and0
Access is Denied
  • Total Posts : 8337
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Flying with software and swapff macro 2014/04/06 12:10:47 (permalink) ☄ Helpfulby SeanD 2014/04/06 12:26:05
#4
SeanD
Super Member
  • Total Posts : 475
  • Reward points : 0
  • Joined: 2009/10/23 07:48:32
  • Location: Dark Rural Northumberland
  • Status: offline
Re: Flying with software and swapff macro 2014/04/06 12:29:22 (permalink)
0
Guys
many thanks yet again. To both 1and0 and Ian.M very great respect. As ever knowledgeable and helpful.
SeanD
#5
Jump to:
© 2018 APG vNext Commercial Version 4.5