I don't pretend to be a C guru, but this seems simple enough. (I didn't read the whole thread, I could be missing something) Isn't this just int My_Table[4] =3D {0x84,0x04,0x40,0x80}; then later the call is something like NewVal =3D My_Table[(Index_Val & 0x03)]; A quick bit of Google reveals this link http://embeddedgurus.com/stack-overflow/2010/01/a-tutorial-on-lookup-tables= -in-c/ Seems relevant. -Denny Hello all, > Could someone please help me do this in C? > Thanks, > rich! > > On 9/14/2015 11:14 AM, Byron Jeff wrote: > > Richard, > > > > Your description below screams table. Since it's only 2 bits, the table > > would be 4 entries long: > > > > TableA: ; W is input. Returns table entry in W. > > andlw 0x3 ; make sure only 2 lowest bits are used > > addwf PC,F ; jump to appropriate table entry > > retlw 0x82 ; return 1001 in bits 7-6,3-2 if input is 00 > > retlw 0x04 ; return 0010 in bits 7-6,3=3D2 if input is 01 > > retlw 0x40 ; return 0100 in bits 7-6,3=3D2 if input is 10 > > retlw 0x80 ; return 1000 in bits 7-6,3=3D2 if input is 11 > > > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .