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 Make a similar table for B. Then all you'd need to do is read the port, clear the output bits, call the table routine, OR back in the results, and write the whole mess back to the port. Hope this helps, BAJ On Mon, Sep 14, 2015 at 10:31:15AM -0500, Richard R. Pope wrote: > Jan-Erik, > I guess my next question is about packing the register. The RA0-1=20 > and RB0-1 bits are my inputs. On Port A the output pins are 2-3 and 6-7.= =20 > On Port B it is 2-5. So if I have two output registers. One called=20 > OutputA and the other OutputB. When the input is 0-0 then the output is=20 > 1-0-0-1. If the input is 0-1 then the output is 0-0-1-0. If it is 1-0=20 > the output is 0-1-0-0 and if it is 1-1 the the output is 1-0-0-0. I=20 > guess we should define some constants called Bit# such as Bit0, Bit1,=20 > Bit2 and so forth to Bit7. These should be set to 1, 2, 4, 8, and so=20 > forth up to 128. We first have to clear the registers to zero with=20 > OutputA or B =3D 0; So do we add RA, B 0 and 1 together? And here is wher= e=20 > I get lost. I just don't understand how to turn RA and B 0 and 1 in to=20 > the proper number to put into the output bits. Would you please help me=20 > with this. > Thanks, > rich! >=20 > P.S. This is how it should look. > --------------------------------- ---------------------------------- > | Input | Output | =20 > | Input | Output | > | Bits | Bits PortA | = =20 > | Bits | Bits PortB | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|-----|------| > | 1 | 0 | 2 | 3 | 6 | 7 | =20 > | 1 | 0 | 2 | 3 | 4 | 5 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|-----|------| > | 0 | 0 | 1 | 0 | 0 | 1 | =20 > | 0 | 0 | 1 | 0 | 0 | 1 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| > | 0 | 1 | 0 | 1 | 0 | 0 | =20 > | 0 | 1 | 0 | 1 | 0 | 0 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| > | 1 | 0 | 0 | 0 | 1 | 0 | =20 > | 1 | 0 | 0 | 0 | 1 | 0 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| > | 1 | 1 | 0 | 0 | 0 | 1 | =20 > | 1 | 1 | 0 | 0 | 0 | 1 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| > Thanks, > rich! >=20 >=20 > On 9/13/2015 6:00 AM, Jan-Erik S=F6derholm wrote: >=20 > --=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 --=20 Byron A. Jeff Associate Professor: Department of Computer Science and Information Technol= ogy College of Information and Mathematical Sciences Clayton State University http://faculty.clayton.edu/bjeff --=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 .