Searching \ for '[PIC]: short inline table' 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/memory.htm?key=table
Search entire site for: 'short inline table'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: short inline table'
2001\01\15@185812 by Germain Morbe

flavicon
face
Im so sorry,
made a fault in subtracting the index. Here is the right way.

Enter with pointer in w
Exit with Value1 to Value4 in w
...
addwf    pcl,f
xorlw    ( 0 xor VALUE1 xor VALUE2 xor 1 )
xorlw    ( 1 xor VALUE2 xor VALUE3 xor 2 )
xorlw    ( 2 xor VALUE3 xor VALUE4 xor 3 )
xorlw    ( 3 xor VALUE4 )
...

Germain

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\01\15@204754 by Bob Ammerman

picon face
Very nice! I expect this is probably optimal in space if not in time.

You could of course do the same thing with appropriate ADDLW or SUBLW
instructions.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2001\01\16@020727 by Andrew Warren

face
flavicon
face
Bob Ammerman <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> > Enter with pointer in w
> > Exit with Value1 to Value4 in w
> > ...
> > addwf    pcl,f
> > xorlw    ( 0 xor VALUE1 xor VALUE2 xor 1 )
> > xorlw    ( 1 xor VALUE2 xor VALUE3 xor 2 )
> > xorlw    ( 2 xor VALUE3 xor VALUE4 xor 3 )
> > xorlw    ( 3 xor VALUE4 )
>
> Very nice! I expect this is probably optimal in space if not in
> time.

   It saves one word of program space over the usual "CALL/RETLW"
   method, but the main reason to use it is to save a stack level,
   especially on the 12-bit PICs whose stacks are only 2 levels
   deep.

> You could of course do the same thing with appropriate ADDLW or
> SUBLW instructions.

   Yes.  The example I gave at the 1998 Masters Conference was:

       ADDWF   PCL
       ADDLW   (A)+1 - (B)
       ADDLW   (B)+1 - (C)
       ADDLW   (C)+1 - (D)
       ADDLW   (D)+1 - (E)
       ADDLW   (E)+1 - (F)
       ADDLW   (F)+1 - (G)
       ADDLW   (G)+1 - (H)
       ADDLW   (H)-7

   I like Germain's XOR method better, though, since it makes it
   easier to see what's going on.

   -Andy


=== Andrew Warren - fastfwdspamKILLspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\01\16@050412 by Simon Nield

flavicon
face
bob:
>You could of course do the same thing with appropriate ADDLW or SUBLW
>instructions.

downside/difference of using anything other than xorlw being that C and DC flags get changed
unnecessarily. xorlw only corrupts the Z flag.

regards,
Simon

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2001\01\16@063444 by Germain Morbe

flavicon
face
Anrew, Simon,

as you found also, the main reason for such construct besides the flags is
to save one stack level. While this especially makes sense on the 12 bit
core which only has 2, please also note that ADDLW and SUBLW are not
available at that core!

regards, Germain

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


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