Searching \ for 'MPLAB & XORing' 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/languages.htm?key=mplab
Search entire site for: 'MPLAB & XORing'.

Truncated match.
PICList Thread
'MPLAB & XORing'
1997\12\22@193719 by Philip Martin

flavicon
picon face
Taa for the replies to the MPLAB question. I also RTFM and found the way
to alter the INTCON bit to force the interrupt.

Next, Ohhh what a night:

Take this snipet-
       movf    rmax,w          ; load w with max time count
       xorwf   r1,f
       btfsc   _z              ; has the max time been reached

What I want to do is compare the value in rmax (value increasing each
interrupt) with a fixed value in r1, read in at the beginning of the
program from some BCD switches.

What I've realised is that the result of the XOR is then placed in r1,
overwriting the original data. My thinking now is to first transfer the
data from r1 to w and on to a temporary register and then test the
match. This would however mean doing this every pass (and in quite a few
locations).

Is this the best way of preserving the data in r1, or is there a better
way?

TIA,

--
Philip Martin   ----------------------------------------------------------------
Royal Quays             If at first you don't succeed, try again. Then quit:
North Shields.          no use being a damn fool about it !
                                                       W.C. Fields
email spam_OUTphilipTakeThisOuTspamphilmart.demon.co.uk

1997\12\22@201102 by Mark Thatcher

flavicon
face
part 0 1443 bytes
       movwf   rmax,w
       xorwf   r1,w            ; do the xor, but put result in W
       btfsc   _z

Mark

----------
From:   Philip Martin
Sent:   Tuesday, 23 December 1997 8:25
To:     .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
Subject:        MPLAB & XORing

Taa for the replies to the MPLAB question. I also RTFM and found the way
to alter the INTCON bit to force the interrupt.

Next, Ohhh what a night:

Take this snipet-
       movf    rmax,w          ; load w with max time count
       xorwf   r1,f
       btfsc   _z              ; has the max time been reached

What I want to do is compare the value in rmax (value increasing each
interrupt) with a fixed value in r1, read in at the beginning of the
program from some BCD switches.

What I've realised is that the result of the XOR is then placed in r1,
overwriting the original data. My thinking now is to first transfer the
data from r1 to w and on to a temporary register and then test the
match. This would however mean doing this every pass (and in quite a few
locations).

Is this the best way of preserving the data in r1, or is there a better
way?

TIA,

--
Philip Martin   ----------------------------------------------------------------
Royal Quays             If at first you don't succeed, try again. Then quit:
North Shields.          no use being a damn fool about it !
                                                       W.C. Fields
email philipspamKILLspamphilmart.demon.co.uk

1997\12\22@204046 by Harold Hallikainen

picon face
On Tue, 23 Dec 1997 00:25:09 +0000 Philip Martin
<.....philipKILLspamspam.....PHILMART.DEMON.CO.UK> writes:
{Quote hidden}

       How about just setting the destination of the XOR to w instead of
file?  this destroys w, but leaves your memory fine.

>        movf    rmax,w          ; load w with max time count
>        xorwf   r1,0           ; Set Z if equal, destroys W,
maintains r1
>        btfsc   _z              ; has the max time been reached
>


Harold

1997\12\22@210034 by Dmitry Kiryashov

flavicon
face
Harold Hallikainen wrote:

> >What I want to do is compare the value in rmax (value increasing each
> >interrupt) with a fixed value in r1, read in at the beginning of the
> >program from some BCD switches.
> >
>         How about just setting the destination of the XOR to w instead of
> file?  this destroys w, but leaves your memory fine.
>
> >        movf    rmax,w          ; load w with max time count
> >        xorwf   r1,0           ; Set Z if equal, destroys W, maintains r1
> >        btfsc   _z              ; has the max time been reached

This will not destroy W because easy to do the same XORWF again and
restore W ;)

WBR Dmitry.
PS.
       movfw   A
       addwf   B,w
       xorwf   C,w
       skpnz
       ...             ;probably GOTO or CALL command

       xorwf   C,w     ;restore A+B in W
       ...

1997\12\23@113315 by Justin Crooks

flavicon
face
How about:
       movf    rmax,W
       xorwf   r1,F
       skpz
       .set flag...
       xorwf   r1,F

Xor a register twice with same W and, voila, the original data is back.

       I don't see any reason to xor though...
       Why not just:

       movf    rmax,w
       subwf   r1,W
       skpnz

       ???

----------
{Quote hidden}

----------------------------------------------------------------
> Royal Quays             If at first you don't succeed, try again. Then
quit:
> North Shields.          no use being a damn fool about it !
>                                                         W.C. Fields
> email @spam@philipKILLspamspamphilmart.demon.co.uk

1997\12\23@195334 by Philip Martin

flavicon
picon face
In article <KILLspam19971223163252822.AAA2047KILLspamspamCOD-CAP-2.WYOMING.COM>, Justin
Crooks <RemoveMEjcrooksTakeThisOuTspamWYOMING.COM> writes
>How about:
>        movf    rmax,W
>        xorwf   r1,F
>        skpz
>        .set flag...
>        xorwf   r1,F
>
>Xor a register twice with same W and, voila, the original data is back.
>
>        I don't see any reason to xor though...
>        Why not just:
>
>        movf    rmax,w
>        subwf   r1,W
>        skpnz
>
>        ???
Errr, cos i didn't think of doing it that way.

BTW, is there any difference in code efficiency by doing it by
subtraction rather than xor?

--
Philip Martin   ----------------------------------------------------------------
Royal Quays             If at first you don't succeed, try again. Then quit:
North Shields.          no use being a damn fool about it !
                                                       W.C. Fields
email spamBeGonephilipspamBeGonespamphilmart.demon.co.uk

1997\12\24@112507 by Justin Crooks

flavicon
face
Essentially the only difference is the "leftovers" in W, and you save an
instruction.  If you don't need the XOR result, subwf is simpler.  It can
also be used as a greater than/less than check (the C flag in the status
register).

----------
{Quote hidden}

----------------------------------------------------------------
> Royal Quays             If at first you don't succeed, try again. Then
quit:
> North Shields.          no use being a damn fool about it !
>                                                         W.C. Fields
> email RemoveMEphilipEraseMEspamEraseMEphilmart.demon.co.uk

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