Bjarne Nebelong wrote: > What I need is: > #1 Read in port for 5 bits. > #2 Jump according to the in value. > #3 Do some bit manipulation. > #4 return to #1 > > In 87C750 I have done like this: > > loop: > mov A,P1 ;P0.0 always zero > mov DPTR,#JumpTable > jmp @A+DPTR > > JumpTable: > ajmp A0 ;000000 > ajmp A1 ;000010 > .. > ajmp A31 ;111110 > > A0: > anl p3,#00111000b ;clear bit 0,1,2 > nop > nop > orl p3,#00111000b ;set bit 3,4,5 > ajmp loop > .. > > How can I make this possible in the 16C54 (cheapest I could > find)??? Bjarne: A direct translation of your program looks like this: LOOP: MOVF PORTB,W ;GRAB THE VALUE ON THE PORT. ANDLW 00011111B ;MASK OFF ALL BUT THE LOW 5 ;BITS. ADDWF PC ;JUMP TO TEH APPROPRIATE ELEMENT ;IN THE JUMPTABLE. JUMPTABLE: GOTO A0 ;PORT = xxx00000. GOTO A1 ;PORT = xxx00001. GOTO A2 ;PORT = xxx00010. .... GOTO A31 ;PORT = xxx11111. A0: MOVLW 11111000B ;CLEAR BITS 0,1 AND 2. ANDWF P3 ; MOVLW 00111000B ;SET BITS 3, 4, AND 5. IORWF P3 ; GOTO LOOP ;LOOP BACK. This isn't the most efficient way to do perform the task, but it'll work just fine. The only thing to remember is that the entire jump-table (from "JUMPTABLE:" to "A0:") must be located in page 0 (addresses 000-0FF), since the "ADDWF PC" produces only an 8-bit result. -Andy === Andrew Warren - fastfwd@ix.netcom.com === === Fast Forward Engineering - Vista, California === === === === Custodian of the PICLIST Fund -- For more info, see: === === http://www.geocities.com/SiliconValley/2499/fund.html ===