Searching \ for 'dc flag' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=flag
Search entire site for: 'dc flag'.

Truncated match.
'dc flag'
1997\08\18@114142 by

before you go nuts i thought you'd like to know that

SUBLW 0x06         ;no just d3-d0

does NOT subtract 6 from the W register.

this really subtracts the W register from 6, not exactly what you wish.

the trick i use to get around this one is to add -6

ADDLW 0x00-0x06   ; subtract 6 from W

michael
Just to clarify a point (and be exceedingly anal).

>      SUBLW 0x06         ;no just d3-d0
>
>does NOT subtract 6 from the W register.
>
>this really subtracts the W register from 6, not exactly what you wish.

Actually, subtraction in the PIC adds the Negative to the number:

SUBLW 0x06

Is Actually:

w = 6 + (( w ^ 0x0FF ) + 1 )

This leads to all kinds of wild and wonderful things.  Before using either
subtract in the PIC, write a few of simple programs to experiment with
subtract and see what the results are before using them in the program.

>the trick i use to get around this one is to add -6
>
>      ADDLW 0x00-0x06   ; subtract 6 from W

Good Trick and one that is more intuitive than using the "SUBLW" instruction.

myke

"One must invoke enough raw truth to punch a hole in the world" - Darl Af
>
> Actually, subtraction in the PIC adds the Negative to the number:
>
>        SUBLW 0x06
>
> Is Actually:
>
>   w = 6 + (( w ^ 0x0FF ) + 1 )
>
> This leads to all kinds of wild and wonderful things.  Before using
either
> subtract in the PIC, write a few of simple programs to experiment with
> subtract and see what the results are before using them in the program.
>
> >the trick i use to get around this one is to add -6
> >
> >      ADDLW 0x00-0x06   ; subtract 6 from W
>
> Good Trick and one that is more intuitive than using the "SUBLW"
instruction.
>
> myke

Myke is right. Try the test cases for -1 , 0 , 1. Of the many different
ways that
the various processors that we work on do subtracts the "0" case is the
most
unpredictable in setting thne condition codes.   The carry reflects the
last operation
the following with the addition of one more set of brackets show's the
Microchip
PIC familly subtract.

w = (6 + (( w ^ 0x0FF ) + 1 ))

Walter Banks

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