Searching \ for '[PIC]: 12c509 and SWAPF' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: '12c509 and SWAPF'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 12c509 and SWAPF'
2001\08\15@160810 by Mark Skeels

picon face
oops, sorry about the tag.


does swapf work on the w register?

i.e., does

   swapf    w,0

   swap nibbles in w?


Mark Skeels
Engineer
Competition Electronics
spam_OUTmeskeelsTakeThisOuTspamearthlink.net

Soli Deo Gloria!

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@163548 by uter van ooijen & floortje hanneman

picon face
>     swapf    w,0

The first argument of swapf must be a file register. W is not a file
register, so this does not work. The assembler will accept it, because w and
f are just symbolic equivalents for the 0 and 1 that are used to specify the
destination. Try "swapf f,0": it will be accepted by the assembler for the
same reason that "swapf w,0" is accepted.

Wouter van Ooijen

van Ooijen Technische Informatica: http://www.xs4all.nl/~wf/
Jal compiler for PIC microcontrollers:  http://www.xs4all.nl/~wf/wouter/jal

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@165002 by Scott Dattalo

face
flavicon
face
On Wed, 15 Aug 2001, wouter van ooijen & floortje hanneman wrote:

> >     swapf    w,0
>
> The first argument of swapf must be a file register. W is not a file
> register, so this does not work. The assembler will accept it, because w and
> f are just symbolic equivalents for the 0 and 1 that are used to specify the
> destination. Try "swapf f,0": it will be accepted by the assembler for the
> same reason that "swapf w,0" is accepted.

Just to be clear,

   swapf    w,0

is equivalent to:

   swapf    INDF,W

Since W and INDF are both equ'd to 0.

If you want to swap the nibbles in W then you'll need to do something
like this:

   movwf    temp
   swapf    temp,W


(Unless you're using the 18cxx in which case you can write
   swapf    wreg0,w
)


If you want to shift W left 1 space then:

   movwf    temp
   addwf    temp,w

( a rlf will pick up the carry, but otherwise work just as well)


Shift left 2:

   movwf    temp
   addwf    temp,f
   addwf    temp,f
   addwf    temp,w

Or
   movwf    temp
   rlf      temp,f
   rlf      temp,w
   andlw    0xfc      ;Clear garbage shifted in


Scott

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@165018 by Mark Skeels

picon face
----- Original Message -----
From: "wouter van ooijen & floortje hanneman" <.....wfKILLspamspam@spam@XS4ALL.NL>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: Wednesday, August 15, 2001 3:33 PM
Subject: Re: [PIC]: 12c509 and SWAPF


snip....

> >     swapf    w,0
>
> The first argument of swapf must be a file register. W is not a file

end snip....

Looking at the memory map, I now see that w is not mapped to location 0 in
RAM.

However,

Using my Clearwater Mathias emulator, the following instruction...

incf    w,0

appears to work, actually incrementing the w register.
How come, if swapf doesnt'?

So, incf works, swapf doesn't.

Does this sound correct?

Mark

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@210742 by Olin Lathrop

face picon face
> does swapf work on the w register?

No.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, .....olinKILLspamspam.....embedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@210802 by Olin Lathrop

face picon face
> Unless you're using the 18cxx in which case you can write
>     swapf    wreg0,w

WREG is also mapped to the register space on the 17xxx series.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, EraseMEolinspam_OUTspamTakeThisOuTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\15@210809 by Olin Lathrop

face picon face
> Using my Clearwater Mathias emulator, the following instruction...
>
> incf    w,0
>
> appears to work, actually incrementing the w register.
> How come, if swapf doesnt'?

It doesn't work, only appears to work in you case.  The ",0" causes the
result of the INCF to be written to W, which is why W gets modified.  If W
contains whatever FSR happens to be pointing to, then it will appear to
increment.  If you look into this more carefully you will see that it
doesn't work.  Of course you're messing with some third party emulator, so
who knows what you will see.  Try it with real MPLAB if you continue to have
a problem.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, olinspamspam_OUTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...