Ahhh...that explains it. Didn't think of messing with the PCL myself. The example code I was trying to create was the equiv of a switch statement with the values defined with EQU's. The table comes in when I try to change the switch stmt comparison values. So now I guess all I need to do is change the switch to compare against register values, and have the table routine change the register values based on some trigger. This is cool stuff! What should I try next? Perhaps a B Tree? :-) Thanks! -Neil. ----- Original Message ----- From: "Giorgio De Nunzio" To: Sent: Monday, March 04, 2002 12:45 PM Subject: Re: [PIC]: Tables in PIC assembly lang? > On Mon, 4 Mar 2002, Pic Dude wrote: > > > Still new at this PIC stuff, and trying to think of a way to implement > > tables in a PIC. BTW, I'm experimenting with a 16F872 if that makes > > a diff. > > Here is the standard way to insert a table into the code with a 16f84; no > idea if you have better ways on bigger pics. > > You put the index (starting from 0) into the accumulator and then you > call the subroutine: > > movlw 3 > call readtable > > The subroutine looks like this: > > readtable addwf PCL,F > retlw B'11000000' > retlw B'01100000' > retlw B'00110000' > retlw B'10010000' > > and gives back the w-th value into w. > > Pay attention not to be on the border of a 256 word page. > > Hope this helps. > Ciao > Giorgio > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.