Searching \ for '[PIC] Skip if File Register is 0x00' 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: 'Skip if File Register is 0x00'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Skip if File Register is 0x00'
2009\01\01@175926 by solarwind

picon face
How can I (in MPASM), skip the next instruction if an 8 bit file
register is 0x00? I've looked at decfsz but I can't come up with the
logic to do this efficiently...

--
solarwind

2009\01\01@180053 by solarwind

picon face
Forgot to mention, I'm using PIC 16 series. The 18 series seem to have
a TSTFSZ instruction...

2009\01\01@194119 by Marcel Birthelmer

picon face
INCF <reg>, F
DECFSZ <reg>, F
<conditional instruciton here>
<more instructions>

On Thu, Jan 1, 2009 at 3:00 PM, solarwind <spam_OUTx.solarwind.xTakeThisOuTspamgmail.com> wrote:

> Forgot to mention, I'm using PIC 16 series. The 18 series seem to have
> a TSTFSZ instruction...
> -

2009\01\01@194320 by Jinx

face picon face
> How can I (in MPASM), skip the next instruction if an 8 bit file
> register is 0x00? I've looked at decfsz but I can't come up with the
> logic to do this efficiently...

movf register,w (note - overwrites previous W contents)
skpz

skpz is a pseudonym for btfss status,2

2009\01\01@195008 by Thomas C Sefranek

flavicon
face
tstfsz
 *
 |  __O    Thomas C. Sefranek  .....tcsKILLspamspam@spam@cmcorp.com
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org
----- Original Message -----
From: "solarwind" <x.solarwind.xspamKILLspamgmail.com>
To: "Microcontroller discussion list - Public." <.....piclistKILLspamspam.....mit.edu>
Sent: Thursday, January 01, 2009 5:59 PM
Subject: [PIC] Skip if File Register is 0x00


> How can I (in MPASM), skip the next instruction if an 8 bit file
> register is 0x00? I've looked at decfsz but I can't come up with the
> logic to do this efficiently...
>
> --
> solarwind
> --

2009\01\01@195145 by Harold Hallikainen

face
flavicon
face

> How can I (in MPASM), skip the next instruction if an 8 bit file
> register is 0x00? I've looked at decfsz but I can't come up with the
> logic to do this efficiently...
>


There's a pseudoinstruction called tstf . It is the same as movf x,f or
move a file register to itself. This will set the status Z bit if the file
register was zero. So, you'd do something like this:

 movf FileRegister,f
 btfss STATUS,f

Harold

--
FCC Rules Updated Daily at http://www.hallikainen.com - Advertising
opportunities available!

2009\01\01@195320 by Jinx

face picon face
> How can I (in MPASM), skip the next instruction if an 8 bit file
> register is 0x00? I've looked at decfsz but I can't come up with the
> logic to do this efficiently...

BTW, you can test for any value with xor

movlw 0xValue (or movf Value,w to compare registers)
xorwf register,w

Z=1 if register = Value

skpz or bz, skpnz or bnz

2009\01\01@195446 by solarwind

picon face
On Thu, Jan 1, 2009 at 8:42 PM, Jinx <EraseMEjoecolquittspam_OUTspamTakeThisOuTclear.net.nz> wrote:
>> How can I (in MPASM), skip the next instruction if an 8 bit file
>> register is 0x00? I've looked at decfsz but I can't come up with the
>> logic to do this efficiently...
>
> movf register,w (note - overwrites previous W contents)
> skpz
>
> skpz is a pseudonym for btfss status,2

OH! Could I also do:

movf register, f
skpz

?

And how can I check if a certain register equals a literal? Or if
register a == register b?


And thanks for response!
--
solarwind

2009\01\01@195643 by solarwind

picon face
part 1 731 bytes content-type:text/plain; charset=GB2312 (decoded quoted-printable)

On Thu, Jan 1, 2009 at 7:49 PM, Thomas C Sefranek <wa1rhpspamspam_OUTarrl.net> wrote:
> tstfsz

That instruction is not available on 16F...

Just found:

MOVF Move f
Syntax: [ label ] MOVF f,d
Operands: 0 f 127
d [0,1]
Operation: (f) (dest)
Status Affected: Z
Description: The contents of register 'f' is
moved to a destination dependent
upon the status of 'd'. If d = 0,
destination is W register. If d = 1,
the destination is file register 'f'
itself.
--------------------------------
--------------------------------
d = 1 is useful to test a file
register since status flag Z is
affected.
--------------------------------
--------------------------------
-- solarwind



part 2 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2009\01\01@202259 by Jinx

face picon face
> OH! Could I also do:
>
> movf register, f
> skpz

Yes, sorry, I should have said movf register w or f.. movf ,w just
happened to be in some code right in front of me at the time

2009\01\01@203358 by solarwind

picon face
On Thu, Jan 1, 2009 at 9:21 PM, Jinx <@spam@joecolquittKILLspamspamclear.net.nz> wrote:
> Yes, sorry, I should have said movf register w or f.. movf ,w just
> happened to be in some code right in front of me at the time


Just came up with these:

; Skip if f = 0
skpfz        macro        register
       movf     register, f
       btfss    STATUS, Z                                                ; Skip if zero flag is set
       endm

; Skip if f = w
skpfwe       macro        register
       xorwf    register, w                                        ; XOR register and w, w will be zero if f = w
       btfss    STATUS, Z                                                ; Skip if zero flag is set
       endm

; Skip if f < w
skpflw       macro        register
       subwf    register, w
       btfsc    STATUS, C                                                ; If C = 0, f < w
       endm

; Skip if f > w
skpfgw       macro        register
       subwf    register, w
       btfss    STATUS, Z                                                ; Skip if f = w
       btfss    STATUS, C                                                ; If C = 1, f > w
       endm

Thanks!


--
solarwind

2009\01\01@205452 by Jinx

face picon face
> And how can I check if a certain register equals a literal? Or if
> register a == register b?

I mentioned xor, there's also sub

For example, if register = 0x73

movlw 0x72
subwf register,w

Z = 0

movlw 0x73
subwf register,w

Z = 1

movlw 0x74
subwf register,w

Z = 0

On the 18F this subtraction sets N (ie W = 0xFF = -1). The 18F also
has comparison instructions for register vs W. CPFSEQ, CPFSGT
and CPFSLT

2009\01\02@080303 by olin piclist

face picon face
solarwind wrote:
> Forgot to mention, I'm using PIC 16 series. The 18 series seem to have
> a TSTFSZ instruction...

And this is relevant to...?


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\02@080640 by olin piclist

face picon face
solarwind wrote:
> How can I (in MPASM), skip the next instruction if an 8 bit file
> register is 0x00?

    banksel  myreg
    movf     myreg     ;set Z bit according to MYREG contents
    skip_z             ;is MYREG zero ?
    goto     someplace ;no, go process MYREG not zero

Note that SKIP_Z is one of my macros.  It expands to the bit test
instruction on the Z bit in STATUS, but it's a lot more intuitive than
writing that out.  There are a bunch of other macros, like SKIP_NZ,
SKIP_WLE, and SKIP_WGT that make status bit testing easier.  These are all
in STD.INS.ASPIC, which is part of my PIC development environment described
at http://www.embedinc.com/pic.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\02@081016 by olin piclist

face picon face
Jinx wrote:
>> How can I (in MPASM), skip the next instruction if an 8 bit file
>> register is 0x00? I've looked at decfsz but I can't come up with the
>> logic to do this efficiently...
>
> movf register,w (note - overwrites previous W contents)

You don't have to use W as the destination.  Leave off the W and nothing at
all gets trashed, just the Z flag set according to the contents of the
register.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\02@081211 by olin piclist

face picon face
solarwind wrote:
> And how can I check if a certain register equals a literal?

XORLW, then check the Z bit.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\02@115350 by Tamas Rudnai

face picon face
The names of these macros are not consistent (skpfwe / skpflw). Also the
letter 'L' is common used for 'literal' in MPASM so the macro name is
misleading.

BTW: I would use compare and test macros instead, like CMPWL, CMPFW and
CMPFL, and then macros like SKPEQ, SKPLT, SKPGT, SKPLE, SKPGE. The reason is
that in this way you can have a single comparision and then multiple
conditions saving clock and program memory - especially that you loose W
after these macros.

Cheers,
Tamas


On Fri, Jan 2, 2009 at 1:33 AM, solarwind <KILLspamx.solarwind.xKILLspamspamgmail.com> wrote:

{Quote hidden}

> -

2009\01\02@150550 by olin piclist

face picon face
Tamas Rudnai wrote:
> BTW: I would use compare and test macros instead, like CMPWL, CMPFW
> and CMPFL, and then macros like SKPEQ, SKPLT, SKPGT, SKPLE, SKPGE.
> The reason is that in this way you can have a single comparision and
> then multiple conditions saving clock and program memory - especially
> that you loose W after these macros.

I've found it works best having macros only for the skip that tests the
condition bit.  For example SKIP_WLE and SKIP_WGT are "skip if W was less
than or equal to the other value", and "skip if W was greater than the other
value".  That way you can use SUBLW and SUBWF to set the condition and it
doesn't matter how you got the value into W.

It seems that when people are new to the PIC instruction set, they want to
run out and make macros for every conceivable case.  That may sound like a
good idea at first, but you'll find less is more once you get into it a bit.
Stick with SKIP_Z, SKIP_NZ, SKIP_WLE, and SKIP_WGT for now.  Wait until you
get a few projects of experience before creating more macros because by that
time you probably don't want them anymore.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\02@192951 by Rolf

face picon face
Olin Lathrop wrote:
> Jinx wrote:
>  
>>> How can I (in MPASM), skip the next instruction if an 8 bit file
>>> register is 0x00? I've looked at decfsz but I can't come up with the
>>> logic to do this efficiently...
>>>      
>> movf register,w (note - overwrites previous W contents)
>>    
>
> You don't have to use W as the destination.  Leave off the W and nothing at
> all gets trashed, just the Z flag set according to the contents of the
> register.
>  
I am trying to reconcile this advice with other advice you have given in
the past.

Why leave off the 'W' instead of replacing with 'f'. Leaving the
destination unspecified causes warning messages in the assembler. Given
your tendency to be anal about these things I am surprised your advice
was to simply leave the destination undefined.... is there some deeper
reason I can't yet see?

Rolf

2009\01\02@195534 by Jinx

face picon face
> Why leave off the 'W' instead of replacing with 'f'. Leaving the
> destination unspecified causes warning messages in the assembler

Does it ?

I never use ,f (for one thing ,w sticks out more when there are no ,f)
and can't say I've been bothered with errors

2009\01\03@015940 by Sean Breheny

face picon face
I can vouch for the fact that it used to give a warning message along
the lines of "Destination not specified, assuming F". I have not used
MPASM in a couple of years (all my recent development has been in C)
so I do not know if this has changed.

Sean


On Fri, Jan 2, 2009 at 8:53 PM, Jinx <spamBeGonejoecolquittspamBeGonespamclear.net.nz> wrote:
>> Why leave off the 'W' instead of replacing with 'f'. Leaving the
>> destination unspecified causes warning messages in the assembler
>
> Does it ?
>
> I never use ,f (for one thing ,w sticks out more when there are no ,f)
> and can't say I've been bothered with errors
>
> -

2009\01\03@031939 by Jinx

face picon face
> I can vouch for the fact that it used to give a warning message
> along the lines of "Destination not specified, assuming F"

I don't think the error (305 Using default destination of 1 (file)) is
reported any more, although it's still in the list, for MBLAB 7.50
anyway

For years and years I included errorlevel -305, so at one time it
certainly was the case. But I've no idea when it stopped actually
something

If Rolf hadn't mentioned it did, I would still be assuming similarly

2009\01\03@060131 by Jan-Erik Soderholm

face picon face
Jinx wrote:
>> I can vouch for the fact that it used to give a warning message
>> along the lines of "Destination not specified, assuming F"
>
> I don't think the error (305 Using default destination of 1 (file)) is
> reported any more, although it's still in the list, for MBLAB 7.50
> anyway
>
> For years and years I included errorlevel -305, so at one time it
> certainly was the case. But I've no idea when it stopped actually
> something
>
> If Rolf hadn't mentioned it did, I would still be assuming similarly
>

When posting "problem-code" to some forum (such as PIClist)
I personaly think that it is a good idea to include both
",w" and ",f" destiniations. If not only to say that "yes, I
have thought about that also..." If you leave out ",f" you
will probaly get a few questions asking "was that by accident
or by purpose?"...

Jan-Erik.

2009\01\03@062805 by Jinx

face picon face
> When posting "problem-code" to some forum (such as PIClist)
> I personaly think that it is a good idea to include both
> ",w" and ",f" destinations. If not only to say that "yes, I
> have thought about that also..." If you leave out ",f" you
> will probaly get a few questions asking "was that by accident
> or by purpose?"...

Yes, good point. I've been caught out by that. And it's very easy
to miss a ,w ,f mistake

movf typed instead of movff got me during the week. Didn't spot that
one for a while, and it was right there in front of me all the time

movf    <reg1>,<reg2> causes a 202 warning (Argument out of range.
Least significant bits used. Eh ?), but you get a green light with MPASM
and if you don't check the Output window ........ oops

Another possibility for avoiding confusion in some cases might be to
use movfw, which also indicates deliberation

In my colour scheme for MPLAB, movfw <reg> and movf <reg>,
for example, are different. Even after all these years that's still helpful
when debugging

Anything's better than ,0 and ,1 ;-) !!

2009\01\03@070047 by Tamas Rudnai

face picon face
> movf    <reg1>,<reg2> causes a 202 warning (Argument out of range.
> Least significant bits used. Eh ?), but you get a green light with MPASM
> and if you don't check the Output window ........ oops

Have you ever tried these?

   movf    PORTA, INDF
   movf    PORTA, TMR0

Compiles without a single warn and could give some busy time for the
beginners ;-)

Tamas


On Sat, Jan 3, 2009 at 12:26 PM, Jinx <TakeThisOuTjoecolquittEraseMEspamspam_OUTclear.net.nz> wrote:

{Quote hidden}

> -

2009\01\03@073153 by Jan-Erik Soderholm

face picon face
Tamas Rudnai wrote:
>> movf    <reg1>,<reg2> causes a 202 warning (Argument out of range.
>> Least significant bits used. Eh ?), but you get a green light with MPASM
>> and if you don't check the Output window ........ oops
>
> Have you ever tried these?
>
>     movf    PORTA, INDF
>     movf    PORTA, TMR0
>
> Compiles without a single warn and could give some busy time for the
> beginners ;-)

He he, realy good ones, those... :-)

Jan-Erik.

2009\01\03@100133 by olin piclist

face picon face
Rolf wrote:
> Why leave off the 'W' instead of replacing with 'f'.

Because it's easier, and is a well documented and reliable default.  There
is certainly nothing wrong with explicitly using F though.

> Leaving the
> destination unspecified causes warning messages in the assembler.

Not the way I have things set up.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\01\04@033404 by Jinx

face picon face
> INCF <reg>, F
> DECFSZ <reg>, F

Marcel, I owe you one, for putting the inc/dec thought in my mind

Counting routines in a new project move a stepper motor and keep
track of its position. One for clockwise

inc_h    infsnz  end_h_l
        incf    end_h_h
        bra     p_pulse

and one for counter-clockwise

dec_h    decf    end_h_l
        bnn     p_pulse
        decf    end_h_h
        bnn     p_pulse
        clrf    end_h_l
        clrf    end_h_h
        bra     no_p_pulse

I just realised why the count got trashed when moving counter-clockwise

Not now

dec_h    decf    end_h_l
        incf    end_h_l,w
        bnz     p_pulse
        decf    end_h_h
        bnn     p_pulse
        clrf    end_h_l
        clrf    end_h_h
        bra     no_p_pulse

Cheers

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